配置IIS 6.0运行的应用程序MVC3配置IIS 6.0运行的应用程序MVC3
我想我有我的IIS 6服务器上的配置问题,我想看看是否有什么我已经错过了。
我遇到的问题是,随时当一个RedirectToAction(“索引”,“家”)执行(例如在一个方法返回一个ActionResult)我期望我会返回到:
http://servername.domain.com/virtualdirectoryname
但是,相反,我重定向到:
http://servername.domain.com/virtualdirectoryname/virtualdirectoryname
追加到URL的末尾virtualdirectoryname的第二个实例,不能找出为什么 - 这个网址当然会产生404资源n没有发现错误。我在企业Intranet和公共Internet环境中编写和部署了几个MVC3应用程序,但无法弄清楚我做错了什么。我的global.asax.cs似乎确定 -
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if (HttpContext.Current.User != null)
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
if (HttpContext.Current.User.Identity is FormsIdentity)
{
FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;
FormsAuthenticationTicket ticket = id.Ticket;
// Get the stored user-data, in this case, our roles
string userData = ticket.UserData;
string[] roles = userData.Split(',');
HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(id, roles);
}
}
}
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
}
的Application_AuthenticateRequest处理对登录用户角色的存储,但除此之外,似乎很香草。我能想到的唯一想法是,我已经搞砸了虚拟目录。
在执行这些步骤之前,我已经验证了.NET框架的MVC3和v4.0安装在服务器上。此服务器上还有其他ASP.NET 4.0应用程序正在无故运行。在这台服务器上运行的还有一个MVC2应用程序(也安装了MVC2),并且一直运行正常。
- 我使用IIS管理器创建了主“默认站点”之外的虚拟目录。
- 在该虚拟目录指向的文件夹上设置适当的权限。使用快速的“Hello,World”index.html文件进行测试。
- 将我的开发PC上的应用程序复制到应用程序开发的位置,然后运行到#2中所述的文件夹。
- 更新了Web.Config文件,编辑连接字符串以指向测试数据库服务器;我还在我的开发PC上验证了这些连接字符串。
- 打开网页浏览器,并希望最好。
任何援助非常感谢。
谢谢!
但问题是http://servername.domain。com/virtualdirectoryname/virtualdirectoryname导致404资源未找到错误。 –
转到IIS中的应用程序并右键单击它并选择“浏览”。浏览器中的URL是什么样的? – 2011-11-18 21:22:17
servername.domain.com/virtualdirectoryname/virtualdirectoryname –