asp.net mvc5登录帐户时无法创建或上传文件

时间:2015-08-30 15:32:02

标签: asp.net asp.net-mvc-5 asp.net-identity

本地调试没有问题。但是当我将程序上传到主机时,如果没有登录帐户,请运行此控制器:

System.IO.File.WriteAllText(HttpContext.Server.MapPath("~/1.txt"), "123", System.Text.Encoding.UTF8);
ViewBag.content = System.IO.File.ReadAllText(HttpContext.Server.MapPath("~/1.txt"));

它可以创建一个文件到根目录,但是当我登录帐户时,再次运行Controller,它无法创建文件。它说拒绝访问路径“XX”。< / strong>
是托管问题还是代码?
当我将mvc5简单会员网站上传到主机时,问题又出现了。

public ClaimsIdentity CreateIdentity(User user, string authenticationType)
    {
        ClaimsIdentity _identity = new ClaimsIdentity(DefaultAuthenticationTypes.ApplicationCookie);
        _identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName));
        _identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.UserID.ToString()));
        _identity.AddClaim(new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity"));
        return _identity;
    }


var _identity = userService.CreateIdentity(_user, DefaultAuthenticationTypes.ApplicationCookie);

如果是托管文件夹权限的问题,当我没有登录时,它就无法创建文件,对吗?

0 个答案:

没有答案