【发布时间】:2015-10-23 08:58:32
【问题描述】:
在 MVC 安全方面我是个菜鸟,因为我通常使用自己的安全性,所以请多多包涵。
我有一个开箱即用的 MVC5 应用程序。
当我在本地运行它时一切正常,但在我将它部署到远程网络服务器后,我遇到了身份验证问题。
项目附带的页面作为标准打开正常(主页、关于等),但是当我尝试打开我自己的页面时,出现此错误:
登录失败。登录来自不受信任的域,无法使用 使用 Windows 身份验证。
在尝试引用模型的视图的第一行引发错误。
我没有在 web.config 中添加任何内容来允许或拒绝身份验证。
配置摘录如下所示:
<system.web>
<authentication mode="None" />
<compilation targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="LessAssetHandler" path="*.less" verb="GET" type="BundleTransformer.Less.HttpHandlers.LessAssetHandler, BundleTransformer.Less" resourceType="File" preCondition="" />
</handlers>
<security>
<authorization>
<add accessType="Allow" users="?" />
</authorization>
</security>
</system.webServer>
我需要做什么才能允许访问其他页面?
[编辑]
Home 控制器工作正常。它是开箱即用的标准,如下所示:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace ASP.NET_MVC5_Bootstrap3_3_1_LESS.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
}
}
【问题讨论】:
-
您可能在“标准”控制器上有一个全局
AuthorizationFilter和一个AllowAnonymous过滤器属性? -
Home 控制器没有
AllowAnonymous过滤器,并且工作正常。我在整个解决方案中搜索了AuthorizationFilter,但没有找到。 -
Home 控制器没有
AllowAnonymous过滤器,并且工作正常。我在整个解决方案中搜索了AuthorizationFilter,但没有找到。 -
(家庭控制器添加代码)
标签: c# .net asp.net-mvc authentication