.net 4.0 URL重写.NET 4不工作?
我一直在尝试在.NET4中重写URL的最基本示例,但在本地或IIS服务器上,什么都不能工作 这是我的global.asax文件.net 4.0 URL重写.NET 4不工作?,.net-4.0,url-rewriting,.net 4.0,Url Rewriting,我一直在尝试在.NET4中重写URL的最基本示例,但在本地或IIS服务器上,什么都不能工作 这是我的global.asax文件 <%@ Application Language="C#" %> <script runat="server"> void Application_Start(object sender, EventArgs e) { // Code that runs on application startup RegisterRout
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RegisterRoutes(System.Web.Routing.RouteTable.Routes);
}
public static void RegisterRoutes(System.Web.Routing.RouteCollection routeCollection)
{
routeCollection.MapPageRoute("RouteForCustomer", "Customer/{Id}", "~/Customer.aspx");
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
</script>
我刚得到HTTP找不到?您的
“Customer/{id}”
中的空格是什么?很抱歉,不知道为什么代码中没有空格…我已经更新了它,现在它显示了我的global.asax文件中的正确代码。
http://localhost:3564/Customer/1