1

I have GenericPagecontroller in my project which renders GenericPage.aspx. There are links in the homepage and in two other pages for this GenericPageconroller.Now based on from where it is invoked, i have diiferent data to pass in to the GenericPage.aspx. ie If the Controller is requested from HomePage i have different set of data to show in the view and if it from other page i need to display diiferent set of data in the view. As of now i have kept an optional parameter in the Index method (the default method in GenericController) and added a querystring in the URL which holds the current page's name. Thus from the paramter i find from which link the request comes and load the appropriate data into the view.

Is there any way to achieve this instead having a querystring which carries the related information...? some way to dynamically to find this ?

2 Answers 2

2

you can check Request.UrlReferrer which contains the referring page.

This method is not 100% reliable however.

Sign up to request clarification or add additional context in comments.

3 Comments

Paul@: yes, i guess i am left with no other option since i have a main page and all other other pages will be jquery tabs inside the main page,so from where ever i click i get the Mainpage's URL which is obvious..
@Dainel, I don't think you should use the querystring though, use a parameter and a route!
One more problem is the modules are separated into Areas
1

May be you can use TempData for storing the url before redirecting, however System.Web.HttpContext.Current.Request.UrlReferrer should help you

1 Comment

I would suggest to add more explanation. What it does? Why? How?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.