mercredi 8 mars 2017

How to maintain the right URL in C#/ASP.NET?

I am given a code and on one of its pages which shows a "search result" after showing different items, it allows user to click on one of records and it is expected to bring up a page so that specific selected record can be modified.

However, when it is trying to bring up the page I get (by IE) "This page cannot be displayed".

It is obvious the URL is wrong because first I see something http://ift.tt/2mZlcu0 then it turns into http://localhost:61123/ProductPage.aspx

I did search in the code and found the following line which I think it is the cause. Now, question I have to ask:

What should I do to avoid using a static URL and make it dynamic so it always would be pointing to the right domain?

string url = string.Format("http://localhost:61123/ProductPage.aspx?BC={0}&From={1}", barCode, "Search");

Response.Redirect(url);

Thanks.




Aucun commentaire:

Enregistrer un commentaire