我找到了解决办法。如果你想的index.html是在你的MVC应用程序的根(即旁边的控制器/模型/视图/应用程序数据等文件夹),你可以这样做:
说你有home.html
,aboutus.html
和contactus.html
。
//this route matches (http://mydomain.com/somekindofstring)
routes.MapRoute(
"SingleRootArg",
"{id}",
new { controller = "Home", action = "Details", id=""});
// so now that you have your route for all those random strings.
// I had to do this for vanity urls. mydomain.com/ronburgandy etc. however,
// mydomain.com/index.html will also come in just how you'd expect.
//Just an example of what you COULD do. the user would see it as root html.
Public ActionResult Details(string id)
{
//let me save you the trouble - favicon really comes in as a string *ANGER*
if(String.IsNullOrEmpty(id) || id.ToLower().Contains("favicon.ico"))
return Redirect("~/index.html");
if(id == "aboutus.html")
return Redirect("~/aboutus.html");
if(id == "contactus.html")
return Redirect("~/contactus.html");
if(id == "index.html")
return Redirect("~/index.html");
}
index.html
aboutus.html
index.html
现在是在同一水平作为我的csproj文件。
也许你会得到serverfault.com – tzenes 2010-03-11 04:47:31
更好的反应这不是一个IIS7问题,它是一个ASP.NET MVC的问题。默认的文件被不使用ASP.NET MVC – 2010-03-12 02:24:49
时担任完美其实我很困惑为什么会需要做 – 2010-03-12 02:33:55