1

In my controller action I return a view and I also need to update the url in the browser so if the request url is test.site.testsite.com I want to change it to search.site.testsite.com how can I do this.

Thanks

2 Answers 2

1

So I'm not positive about sub-domains but HttpContext.RewritePath() allows you to modify the URL. This should give you a start.

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

2 Comments

I'll give it a try. Will this work using VS 2010 built server? Or should I deploy on test box with IIS 7?
That didn't work. Lets say the url is search.site.testsite.com the pages loads. Then the user types in abcd.site.testsite.com since this new url will result in a redirect to search.site.testsite.com and since we are already on that page using HttpContext.RewritePath doesn't change the url.
0

You can achieve the above by following,

  1. In IIS host two WebSites (test.site.testsite.com and search.site.testsite.com) both pointing to same physical/virtual directory.

  2. In the Controller action , you can use a filter attribute which will redirect all search request to search.site.com.

Comments

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.