Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MVC Rewrite URL Through Router in ASP.NET

Posted on 2011-03-06
10
Medium Priority
?
878 Views
Last Modified: 2012-05-11
1) routes.Add("Articles", New Route("{product_name}/{c_id}/{sc_id}", New WebFormRouteHandler("~/products.aspx")))

We get url of about path

http://www.sitename.com/Articles/1/17

But problem is that When i m on this page then we move out on the another page
so my url is

http://www.sitename.com/Articles/1/aboutus

but Actual it should be

http://www.sitename.com/aboutus

Looking forward for response.
0
Comment
Question by:citadelind
  • 6
  • 4
10 Comments
 
LVL 14

Expert Comment

by:robasta
ID: 35053426
its probably because the link to About us  on the Articles page is something like this:

<a href="aboutus">xxx</a>


this is relative to the current url and assumes that the page is at the same directory level. What you need to do is add a trailing slash that will say the page/path is at the root i.e.

<a href="/aboutus">xxx</a>

If you are using the helper methods to generate the links, you need to include the controller (e.g. Home)
0
 

Author Comment

by:citadelind
ID: 35053750
It is not working. Please give me proper solution which i given to you.

It is same problem. Please give me example how can i do?
0
 
LVL 14

Expert Comment

by:robasta
ID: 35053877
post the html
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:citadelind
ID: 35054051
I am attaching my global.aspx as txt format file so please check it.

and i also set url of

<a href="Productname/1/17">xxx</a> Global.txt
0
 
LVL 14

Expert Comment

by:robasta
ID: 35054163
post the link to 'aboutus'. i dont think its the routing thats causing the problem. How are you linking from this page: http://www.sitename.com/Articles/1/17 to AboutUs?
0
 

Author Comment

by:citadelind
ID: 35054195
Ya when i write
http://www.sitename.com/Articles/1/17 to AboutUs

Then it is working but Now problem is that
when i m on this page
http://www.sitename.com/Articles/1/17 

Then now i used another link like (contact us) on this page then url comes

http://www.sitename.com/Articles/1/contactus

So it is wrong,
When i m on the page then i used contact us link then it should open

http://www.sitename.com/contactus

This format.
I hope you are getting me.
0
 
LVL 14

Accepted Solution

by:
robasta earned 2000 total points
ID: 35054276
i get you.

here is how html links work:

if you are on page http://www.sitename.com/Articles/1/17 , and on that page, you need to link to http://www.sitename.com/aboutus , then the <a href=""> link should be:

Absolute Link:<a href="http://www.sitename.com/aboutus">

 or

Relative to the site <a href="/aboutus">

If (and im guessing thats how your links are currently working) you have <a href="aboutus">, this is relative to the current directory.

This is how Html links work, it should not have anything to do with the routes you specified. Are you using a master page? if so, post it here.
0
 

Author Comment

by:citadelind
ID: 35054375
Thanks i got solutions about this issue.
Thank you.

But one problem facing

When i m on the page
http://www.sitename.com/Articles/1/17 

All images are gone, bz my directory is images/logo.jpg on the root folder.
so when i am using about link then all images and css are gone.

Please give me solution how can i access all the images and css this page.

0
 

Author Comment

by:citadelind
ID: 35054432
you can ans me image issue on this new question i posted

http://www.experts-exchange.com/Programming/Languages/.NET/Q_26867559.html
0
 

Author Closing Comment

by:citadelind
ID: 35056420
good work
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question