So I've been using php, and switched to ASP.NET because I love it. Anyway... I've been developing my own website and such, but I cannot figure this out for the life of me!
What I have:
string val = HttpContext.Current.Request["Header"];
// filename: index.aspx
// what I need to get
if (val == "random")
{
renderA.Random("randoms.html");
}
else
{
renderA.Index("index.html");
}
What it returns in the URI
/index.asp?random
What I wish it would look like:
/index.aspx/random/
Is there someway I can fix this problem?
You should look at switching to an MVC site; it will provide you the functionality you are looking for.
This is from older releases, but you'll get the idea: Scott Guthrie talking about mvc framework
Add a Global Application Class
to your project (Global.asax file), then you can do the following:
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RegisterRoutes(RouteTable.Routes);
}
void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("random", "random", "~/index.html");
}
You will need a reference to System.Web.Routing
<%@ Import Namespace="System.Web.Routing" %>
Learn more:
http://msdn.microsoft.com/en-us/library/cc668201.ASPX
http://www.codeproject.com/Articles/77199/URL-Routing-with-ASP-NET-4-0
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.