Reputation: 313
I am making an asp.net web application using notepad. I do not want to use visual studio so please do not suggest that.
I am trying to make my URL's SEO friendly, and am trying to implement a global.asax
page which I can use to implement MapPageRoute
.
Below is the whole of my global.asax
page eg there is no other code on this page except for what is below:
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<script runat="server">
void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("","/about","~/about.aspx");
}
</script>
The intention is that when the user goes to:
www.mywebsite.co.uk/about
they are redirected to the page:
www.mywebsite.co.uk/about.aspx
From my experience with MapPageRoute
, I have implemented this properly.
However, I am getting a 404 file not found error, so it is obvisouly not working properly.
Is it that I need to compile this page before it will work properly, or do I need to lay it out differently, or is it something else?
Or is my MapPageRoute
layout incorrect?
Upvotes: 0
Views: 1882
Reputation: 8475
You need to give the route a name (1st parameter) that is not null or empty. You will not see the .aspx in the address bar at all, but your assumptions are correct. However, make sure you are actually registering the routes from Global.asax in the Application_Start method or whatever your startup routine is.
Upvotes: 1