How to route any extension with asp.net 4 routing?
-
14-11-2019 - |
题
I'm trying to handle domain requests like whois.innovacube.com/anydomain.com like whois.domaintools.com/stackoverflow.com
My global.asax file contains code below and it handles requests like /test :
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<script runat="server">
void RegisterRoutes(RouteCollection routes)
{
routes.Ignore("{resource}.axd/{*pathInfo}"); // ignore web resources etc
routes.MapPageRoute("domain", "{domain}", "~/default.aspx");
}
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
</script>
解决方案
I've solved problem by creating web.config file and adding lines below:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
其他提示
did you try this
routes.MapPageRoute("domain", "{*domain}", "~/default.aspx");
it should catch all
不隶属于 StackOverflow