Asked by:
can i add something to Response.Redirect

Question
-
User2102072086 posted
hi,
I have used Response.Redirect("~/abc.aspx");
now i want to add "kkk" like so
Response.Redirect("~/kkk/abc.aspx");
to do this i have to change every where in may applicaiton ( webform with mvc) it has many other pages in redirect .
so is there any way that i do it at one place, be it a handler or module or routing etc etc.
Thursday, April 30, 2020 1:40 PM
All replies
-
User753101303 posted
Hi,
Search/replace in your code editor is not enough? If you expect that to change again you could also use this occasion to replace that magic string with a const for example. I generally dislike to keep something in my app for months if not years to "fix" something that doesn't semes that hard to change.
If really need a bit more time to do that you could perhaps have first ~/abc.aspx redirecting to ~/kkk/abc.aspx. kkk is really a folder. You are not moving a web application to a virtual folder under a web site ?
Edit: I meant https://docs.microsoft.com/en-us/visualstudio/ide/finding-and-replacing-text?view=vs-2019#find-in-files-and-replace-in-files
Thursday, April 30, 2020 1:58 PM -
User288213138 posted
Hi rajemessage,
I have used Response.Redirect("~/abc.aspx");
now i want to add "kkk" like so
Response.Redirect("~/kkk/abc.aspx");
to do this i have to change every where in may applicaiton ( webform with mvc) it has many other pages in redirect .
so is there any way that i do it at one place, be it a handler or module or routing etc etc.
According to your description, I couldn’t understand your requirement clearly.
If abc.aspx exists under your kkk folder, then Response.Redirect ("~/kkk/abc.aspx") will work.
If I misunderstand your requirement, please post more details information about your requirement.
Best regards,
Sam
Friday, May 1, 2020 2:36 AM -
User2102072086 posted
I do not want to change Response.Redirect("~/abc.aspx");
but I want this effect ( Response.Redirect("~/kkk/abc.aspx");)with out changing above first line, buy adding some module or handler in pipeline.
that means I do not want to change the old code.
Friday, May 1, 2020 4:42 AM -
User288213138 posted
Hi rajemessage,
I do not want to change Response.Redirect("~/abc.aspx");
but I want this effect ( Response.Redirect("~/kkk/abc.aspx");)with out changing above first line, buy adding some module or handler in pipeline.
that means I do not want to change the old code.
Can you tell me what is the application scenario for doing this?
In my opinion, Response.Redirect ("~ / abc.aspx") and Response.Redirect ("~ / kkk / abc.aspx") are both hard-coded, they have no essential difference.
Best regards,
Sam
Friday, May 1, 2020 6:45 AM -
User753101303 posted
Then see for example https://www.jondjones.com/architecture/continuous-intergration/iis/ultimate-guide-to-creating-url-rewrite-rules-within-iis/ and the very first sample.
If needs to be installed if not done already:
https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-the-url-rewrite-moduleFriday, May 1, 2020 10:09 AM