Akshay Bhardwaj
Akshay Bhardwaj

Reputation: 65

Asp.net routing between different web forms

I am creating a website and I'm trying to implement routing feature. Most of the time it works fine, but I've found a problem while routing between different web forms placed at different levels from the root of the website.

enter image description here

The above picture shows all the routes defined and picture below shows the solution explorer of my project:

enter image description here

Home page(home.aspx) of my website is shown below:

enter image description here

On clicking the picture it opens a new page(singlepage.aspx) with whole article about the topic and contains the required url(sitename/heading/querystring):

enter image description here

But from there when i click on HOME button, it does not take me to home page, but instead gets me to the url like this:

enter image description here

Seems like it is not calling the "routeHome" route, instead calls "routeSinglePage".

This is how the html for taking us to HOME page is:

enter image description here

So I wanted to know how I can get it to the home page from singlepage.aspx by clicking on HOME button. Do I need to add new routes or something else.

Thanks

Upvotes: 0

Views: 106

Answers (1)

Shahar Bental
Shahar Bental

Reputation: 1001

Change the HTML to:

<li><a href="/Home">Home</a></li>
<li><a href="/AbousUs">About</a></li>
<li><a href="/ContactUs">Contact</a></li>

The "/" indicates an absolute path, you are currently using a relative path and hence the issue.

Upvotes: 1

Related Questions