Whic one correct? Between Response.Redirect(@"~\Default.aspx") and Response.Redirect(@"~/Default.aspx")

It seems the both  Response.Redirect(@"~\Default.aspx") and Response.Redirect(@"~/Default.aspx") can work well,

but could you tell me which one is correct? Thanks!


SuperCool Multiple ZIP - A utility to unzip multiple files and work with multiple zip files

SuperCool Random Number Generator
0
mycwcgr
2/12/2008 3:14:39 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

3 Replies
3318 Views

Similar Articles

[PageSpeed] 7
Get it on Google Play
Get it on Apple App Store

 common practice is to write it like Response.Redirect(@"~/Default.aspx")


Thanx,
[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
0
kaushalparik27
2/12/2008 3:55:41 AM

Hi

Both will work well.

But the Response.Redirect(@"~/Default.aspx")  is the correct one. for all the web url we are using front slash ("/"). So we user the "/" is the good practise.

 

 

 

regards

Ganesan


Ganesan
0
ganesanselvaraj
2/12/2008 4:01:35 AM

 both should result the same. But as per best practices always use Response.Redirect(@"~/Default.aspx") as you do not know where you stuck and then this may be difficult to debug.


Ravi |   Share Knowledge   |   Online messengers  
0
ravipahuja1
2/12/2008 5:08:17 AM
Reply:

Similar Artilces:

Should it be Response.Redirect("~/NextPage.aspx") or Response.Redirect("NextPage.aspx") ?
Hi all,For all references to pages and images that are in the same directory as the current ASPX page, is it necessary to use the "~/" prefix to the pages? Both seem to work, although at times when I upload my code to a shared hosting environment, having the "~/" causes the page to error out.Which one is correct and loads faster?Thanks.  There is a difference between the two. the "~/" means starting from the Application root. Let's say you have this file structure. approot/page1.aspx approot/subfolder/page1.aspx approot/subfolder/page2.aspx If I do Response.Redirect("page1.aspx") ...

Response.Redirect("page.aspx") or Server.Transfer("page.aspx") make MasterPage reload infinitely
 I have this problem with my master page. Any idea why is that happening? Post your codePlease click "Mark as Answer" if you think this post answers your question  simplejust add Response.Redirect("myPage.aspx"); in if(!Page.IsPostBack) condition and you will get the error; ...

server.transfer("*.aspx") or Response.Redirect(String.Format("*.aspx?word={0}", HttpUtility.HtmlEncode(Textbox1.Text.Trim)))?
Hello Friends i can go different page with below code lines server.transfer("*.aspx") or Response.Redirect(String.Format("*.aspx?word={0}", HttpUtility.HtmlEncode(Textbox1.Text.Trim))) How can i go different page with this code lines ? For example.. i have table1 and i have page as coulumname.. page value are 1.aspx and 2.aspx and 3.aspx etc. how can i use page for server.transfer("*.aspx") or Response.Redirect(String.Format("*.aspx?word={0}", HttpUtility.HtmlEncode(Textbox1.Text.Trim)))?? Sincerely  Mark as me if my question or my answer ...

addtocart.aspx Response.Redirect("ShoppingCart.aspx")
Need Help ! If someone put items into Shoppingcart, he allways was redirected to Shoppingcart.aspx. Now I want to redirect the Customer to his origination Page. How to do this ? Thank You !! I'd change the referring pages to execute the logic in AddToCart.aspx and then just refresh the page with a message that it was added to the cart (i.e. just use the page postback capability, and dont' re-direct)... Or do you want to enable some sort of "take me back to where I was last at" function from the Shopping Cart page? Thank you for your reply ! I would prefer You...

How to open Response.Redirect("default.aspx") on whole page in page with frames and not in a specific frame?
Hi, I got page with frames.. I want to open default.aspx in whole page, not in a specific frame. how to do it? Thanks, gil. I tried this: Response.Redirect("default.aspx") but it opens on the main frame and not on the whole page. What to do?   One question are you using the redirect inside the frame?,"Mark As Answer" If my reply helped you -- have a look on this thread belowhttp://forums.asp.net/p/1187451/2032032.aspx Regards,Vinz"Code, Beer and Music" that's my way of being a programmer!How to get your Forum Question Answered | Blog | CodeA...

problem is " Response.Redirect(String.Format("asanat.aspx?arama1={0}&deneme={1}", Label1.Text, deneme.Text))"
hello friends when i click node of treeview1, i have error message related to character in below code line deneme and label1 are label.. and it is on master page.. what can problem be ? and i see "word           word" in propertious of deneme of label.. but it should be "word word" Response.Redirect(String.Format("asanat.aspx?arama1={0}&deneme={1}", Label1.Text, deneme.Text)) cheersMark as me if my question or my answer can be helpful for you :)  Response.Redirect(String.Format("asanat.aspx?ar...

Response.Redirect("URL") and target="_blank"
in codebehid  I use Response.Redirect(http://www.google.com.hk/) I want the google page is open in a new Win ,did not cove my page, in html we can use target="_blank" How can I hadle it in Redirect? Thank you Instead of response.redirect try this: response.write("<script>");response.write("window.open('page.html','_blank')");response.write("</script>"); OR Response.Write("<script language='javascript'> window.open('"+ DropDownList1.SelectedValue + "', 'window','HEI...

Tying "Response.Redirect" to an "ItemInserted" event on a FormView
I have a FormView on a page and I need to switch pages after a ItemInserted event occurs. I'm getting a Compiler Error Message: CS1031: Type expected when I attempt the following I tried just pasting Response.Redirect("default.aspx", true); into the ItemInserted field of the formview's properties and it generated the following code in the cs file... using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class Default3 : System.Web.UI.Page{    protected void Page_Lo...

really have no idea with response.Response.Redirect("index.aspx?key=" & String1)
Hi All, I am really having hard time with this. I have a index aspx page which could receive a param from URL, here are exmples http://www.mycompany.com/index.aspx?key=prayer http://www.mycompany.com/index.aspx?key=world http://www.mycompany.com/index.aspx?key=puppy2 there are working very well, no problems. However, I have created another page URLRewriting.aspx Response.Redirect("index.aspx?key=" & string1) As a result, after redirecting , it is different with the one i want. This is just an simple page to redirect to another page. I really have no idea. Can anyone ...

querystring by response.redirect("somepage.aspx") ??
Hi, Does any body know how to transfer values (parameters) while transfering to another page with Response.Redirect("somepage.aspx") ????????? Thanks, eran. 1) Use query string, like you said: Response.Redirect("targetpage.aspx?var1 = " & aValue ) 2) Store stuff in Session variables. 3) Store stuff in cookies. (Only small pieces of info that are not security sensitive.) -- Mike PopeASP.NET User EducationThis posting is provided "AS IS" with no warranties, and confers no rights. Hi, Dim ParmValue As String = "TestParm"...

Response.Redirect(DropDownList.SelectedItem + ".aspx")???
I have a drop down list that when it autopostbacks should redirect the user to the selected value and append the .aspx extension to it. However, when i run the code, the page just redirects to the first item in the list. I tried to use .SelectedValueChanged but wouldn't work. Here's my code. Please help. Thanks.1 protected void ddlNav_OnSelectedIndexChanged(object sender, EventArgs e) 2 { 3 Response.Redirect(ddlNav.SelectedIndex + ".aspx"); 4 } Simple enough, eh?Of course, that's what I thought. LOL ~ I'm sure its something stupid...

different between kernel "Trace","pae" and "default"
I want to know the differences among them. When I instlled opensuse, it uses pae as kernel. After I run "install software", it prompts me to restart system to enable new kernel. When I choose "default kernel" not "pae kernel", it can not display X-windows GUI but only text mode. But if I choose "trace kernel", I can log on X-window like "pae kernel". I couldn't find any differences between them. -- nAthrun ------------------------------------------------------------------------ nAthrun wrote: > > I wan...

.ALLCOL("%COLUMN%", " ", ", ", ", ")
Do you know anyway for me to exclude a subset of columns returned by this function. We have two columns (rec_user and rec_datetime) which are in all of our tables, but when generating triggers I want automatically generate a script which does not include those two columns but does include all other columns in that table. Bruce I should add that I am using PD 9.0.0.580. Bruce "Bruce Lamb" <lamb.bruce@mayo.edu> wrote in message news:6HgI315nCHA.155@forums.sybase.com... > Do you know anyway for me to exclude a subset of columns returned by this > function. ...

Precedence of "where" ("of", "is", "will")?
Nobody on #perl6 today could answer this one. Is: Str | Int where { $_ } the same as: (Str | Int) where { $_ } or: Str | (Int where { $_ }) ? Followup questions, Mr. President: What kind of operators are "where", "of", "is", and "will"? Is there a reason that S03 doesn't list them? What are their precedence(s)? -- Chip Salzenberg - a.k.a. - <chip@pobox.com> Open Source is not an excuse to write fun code then leave the actual work to others. Chip Salzenberg writes: &...

Web resources about - Whic one correct? Between Response.Redirect(@"~\Default.aspx") and Response.Redirect(@"~/Default.aspx") - asp.net.getting-started

Resources last updated: 12/23/2015 4:40:43 PM