我有几个部署到IIS的应用程序。我为每个应用程序创建了一个站点,并使用不同的端口号映射了它们。最近,有人要求我使用虚拟目录,而不是使用其他端口号映射它们。我创建了虚拟目录并为其添加路由。当我尝试在本地测试该应用程序时,我得到了403.14。在在线阅读几篇文章后,我对我的web.config文件进行了以下更改
<modules>
<remove name="UrlRoutingModule-4.0"/>
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule,
System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
preCondition="" />
</modules>
我没有包含所有文件名的目录。我在
中更新了路线RouteConfig.cs file to
routes.MapRoute(
name: "Default",
url: "CollegeOfBusiness/{controller}/{action}/{id}",
defaults:
new { controller = "Account", action = "Logon", id = UrlParameter.Optional},
namespaces: new[] { "MyCollege.Controllers" }
);
进行了这些更改之后,我不再得到400.13了;但是,我没有登录页面。我正在获取所有文件的目录。我先运行命令“ aspnet_regiis / i”,然后运行aspnet_regiis -ir以确保这不是注册问题。到目前为止我还没有运气。我正在寻找可以帮助解决此问题的任何信息或资源。
本地系统: Windows 7的 IIS 7.5 Visual Studio 2017 Asp.net MVC 4 jQuery 2.3
更新2018年7月3日@ 9:45
我修改了路线,如下所示。我没有目录列表了。但是,POST和GET未路由到适当的控制器。 页面首次加载时的网址如下所示:
http://localhost/CollegeOfBusiness
我在下面添加了自定义路线。它被添加到默认路由的上方。
RouteConfig.cs file to
routes.MapRoute(
name: "CollegeOfBusiness",
url: "CollegeOfBusiness/{controller}/{action}/{id}",
defaults:
new { controller = "Account", action = "Logon", id = UrlParameter.Optional},
namespaces: new[] { "MyCollege.Controllers" }
);
然后,在底部添加默认路由。
RouteConfig.cs file to
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults:
new { controller = "Account", action = "Logon", id = UrlParameter.Optional},
namespaces: new[] { "MyCollege.Controllers" }
);
当用户单击登录按钮时,帖子URL如下所示:
/CollegeOfBusiness/Account/Logon
答案 0 :(得分:0)
最后,我能够使它正常工作。 1.我删除了以下自定义路由,因为它是不需要的。
RouteConfig.cs file to
routes.MapRoute(
name: "CollegeOfBusiness",
url: "{controller}/{action}/{id}",
defaults:
new { controller = "Account", action = "Logon", id = UrlParameter.Optional},
namespaces: new[] { "MyCollege.Controllers" }
);
如本POST中的建议,我将URL添加到div中并根据ID进行获取。我还将所有js和css文件的src更改为使用@ Url.Action()。
我必须在所有请求之前添加'/ CollegeOfBusiness'
我将应用程序池更改为使用服务帐户。该帐户无权更新数据库,因此我也修复了该问题。