小编RAM*_*Me0的帖子

不同命名空间中的部分类

我可以在不同的命名空间中创建部分类吗?它会正常工作吗?例如:

将Class1.cs

namespace name1
{
    public partial class Foo
    {
        Bar1(){
            return 10;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

class2.cs

namespace name1.name2
{
    public partial class Foo
    {
        Bar2(){
            return 100;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

main.cs

using name1;
using name1.name2;

namespace mainClass
{
    public class mainClass
    {
        Foo classFoo = new Foo();
        int Count = classFoo.Bar1() + classFoo.Bar2();
        // Will Count = 110?
    }
}
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能让它发挥作用?(如果我的例子不正确)

c# silverlight class partial

59
推荐指数
5
解决办法
4万
查看次数

ASP.NET MVC 3使用身份验证

如何使用FormsAuthentication保存内容?我不想通过URL存储UserId.

例如,现在我有这个代码:

//UserController class:
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
  if (repository.ValidateUser(model.Login, model.Password))
  {
    FormsAuthentication.SetAuthCookie(model.Login, model.RememberMe);
    if (Url.IsLocalUrl(returnUrl))
    {
      return Redirect(returnUrl);
    }
    else
    {
      return RedirectToAction("Project", "Index");
    }
  }
  else
  {
     ModelState.AddModelError("", "Incorrect name or password.");
  }
}

return View(model);
}
Run Code Online (Sandbox Code Playgroud)

ProjectController 类:

public ViewResult Index()
{
    return View(repository.GetUserProjects(
        this.ControllerContext.HttpContext.User.Identity.Name));
}
Run Code Online (Sandbox Code Playgroud)

ProjectRepository:

ProjectsContext context = new ProjectsContext();
UsersContext uCnt = new UsersContext();

public IEnumerable<Project> GetUserProjects(String username)
{
    if (String.IsNullOrEmpty(username))
        throw new ArgumentNullException("username", "Login is …
Run Code Online (Sandbox Code Playgroud)

authentication asp.net-mvc-3

22
推荐指数
2
解决办法
3万
查看次数

检测PHP上的操作系统正在运行

我正在处理当前项目的问题,我需要一些帮助:

  1. 功能strtoupper(),mb_strtoupper()等不工作
  2. 我需要设置正确的语言环境才能使它们正常工作
  3. 为此我需要知道PHP上的操作系统正在运行,因为对于Windows正确的命令是setlocale(LC_ALL, "rus");或者setlocale(LC_ALL, "Russian_Russia.1251");对于其他人(我不知道所有其他人是否)setlocale(LC_ALL, 'ru_RU');

但是我找到的所有操作系统检测方法都使用strupper()/ strtolower()检测操作系统......所以现在我有些困惑.我该怎么办.如何检测OS ...

顺便说一句,性能是至关重要的,如果有人知道检测操作系统的好方法和设置正确的语言环境,那就太棒了!

php locale

0
推荐指数
1
解决办法
75
查看次数

标签 统计

asp.net-mvc-3 ×1

authentication ×1

c# ×1

class ×1

locale ×1

partial ×1

php ×1

silverlight ×1