0

I have an ASP.NET web controller that receives requests from the front-end and needs to show a web page from another ASP.NET server. So far I have this and it does the simple job of redirecting:

public ActionResult RedirectToAdminPanel(string url)
{
    return new RedirectResult(url);
}

The url contains some parameters and values, which I transfer to the other server. I need to have a few more I do not want to show in the front-end. An example is a token.

I was going to concatenating the url with those hidden values in the method above but I wonder if there is a better way.

1 Answer 1

2

When you use "RedirectResult", the new URL is sent back to the browser with a 302 status code. Then the browser makes a 2nd request to download the new URL. This means that the browser will need network connectivity to your 2nd server and the URL in the browser will change to show the new URL (including any token you append).

To stop this from happening, your .Net code needs to make the 2nd web request itself. In many cases, you can use the IIS Rewrite module to act as a reverse proxy to do this. If that's doesn't give you enough options, you can make the request yourself by using the WebClient class.

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

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.