My IIS server link is like h t t p s://iis/myApp
I have a redirect in Index. a s p x which is in the root folder
protected void Test_RedirectSSM(object sender, EventArgs e)
{
Response.Redirect("~/UserPages/TestareSSM. a s p x");
}
but on btn click the path become
h t t p s://iis/UserPages/Testare SSM. a s p x, ignoring the root folder myApp
I tried with full path on Response.Redirect
protected void Test_RedirectSSM(object sender, EventArgs e)
{
Response.Redirect("h t t p s:/iis/myApp/UserPages/ TestareSSM . a s p x");
}
but it still ignores myApp. Please help me fix this

Aman GuptaPosted Aug 22, 2024, 5:26 PM
Hi Marius,
The issue you're encountering with
Response.Redirectnot correctly including themyApproot folder in the URL is likely due to how the path is being resolved in the IIS environment. Here's how you can fix it:1. Use
ResolveUrlin code>Response.Redirect:ResolveUrlhelps in resolving the correct path based on the application root, ensuring that themyAppfolder is included in the URL.2. Use
Request.ApplicationPath:Another approach is to manually build the URL using
Request.ApplicationPath, which will ensure that the application’s root folder (myApp) is correctly prefixed in the URL.3. Absolute Path:
If you are dealing with a situation where you must use an absolute path, ensure you correctly structure it, including the full application path:
Summary:ResolveUrl("~/...")is often the most reliable and easiest way to ensure URLs are correctly resolved relative to the application root.Request.ApplicationPathcan be used to dynamically construct paths based on where your application is deployed.myAppportion.These approaches should help ensure that the redirect URL correctly includes your application's root folder (
myApp) when deploying on IIS.Marius VasilePosted Aug 23, 2024, 4:53 AM
Thank you Aman,
I tried all three options and I have the same result, the root folder is considered without myApp
Other redirections, ex. to Index works fine but this one