Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 28, 2012 07:01 PM by Digitborn.com
Apr 28, 2012 12:25 PM|LINK
What is the difference between having base URL in aspx page and codebehind:
public partial class MasterPage : System.Web.UI.MasterPage
protected void Page_Load(object sender, EventArgs e)
Page.Header.Controls.Add(new LiteralControl(@"<base href""http://url/"" />"));
<base href="http://url/" />
It behaves differently in my code. The aspx option is working as expected and codebehind is working ok for images but not for some other stuff in my page.
Apr 28, 2012 05:48 PM|LINK
is the rendered out html exactly the same? Looks so at first glance but just want to make sure.
but not for some other stuff in my page.
Like? And it works if you put the base statement directly in the markup?
Apr 28, 2012 07:01 PM|LINK
It's difficult to say what exactly is happening. I use response.redirect or Button1.PostBackUrl to the same Defualt.aspx and url rewriting. The url rewriting is confusing the path of images, css, etc. etc. I also have a lot of UpdatePanels and AJAX ASP.NET
controls which render in different positions after the response.redirect or Button1.PostBackUrl. That's why i use base url to prevent errors and reordering / not finding paths. When i use it in aspx MasterPage it's ok, when i use it in codebehind images seem
ok, but other stuff not.
Also, i tried path like "~/" which is not working, only base url in aspx is working ok.
Another thing - i don't want the base url in aspx because when i try to debug with Visual Studio (ASP.NET Development Server) it throws some strange error messages out of ajax controls and updatepanels. When i use it in IIS7 localhost it's not giving errors.
p.s. sorry for my bad English, i feel very tired at the moment.