asp.net put base url in web.config file

I want to put my base url in an web.config file, then use it in a link so I can change the url when I deploy.  How do I do that?

This does not work:
                        <asp:HyperLink ID="OpportunitySearchLink" runat="server"
                            NavigateUrl="<%=ConfigurationSettings.AppSettings["baseURL"] %>OpportunitySearch.aspx">Opportunity Search</asp:HyperLink><br />
jackjohnson44Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zkeownCommented:
I think you just need a slight modification:

NavigateUrl='<%=ConfigurationSettings.AppSettings["baseURL"] & "OpportunitySearch.aspx" %>'

Note the single quotes around the entire NavigateURL property
0
OMC2000Commented:
put entry like the following to web.config
      <appSettings>
            <add key="baseURL " value="/Portal" />

make sure that baseURL key in the web.config is terminated with slash or add it before OpportunitySearch.aspx:

%>/OpportunitySearch.aspx"
0
jackjohnson44Author Commented:
Thanks, but that didn't exactly work.  I can get the url to print correctly, but when it is in a tag, it isn't getting displayed correctly.  Meaning when I print it above the link, it looks good.  I think it is the single quote

Here is the code:
<asp:HyperLink ID="OpportunitySearchLink" runat="server"
                            NavigateUrl='<%=ConfigurationManager.AppSettings("baseurl") & "OpportunitySearch.aspx" %>'>Opportunity Search</asp:HyperLink><br />

Here is how it displays when I view source:
<a id="OpportunitySearchLink" href="&lt;%=ConfigurationManager.AppSettings(&quot;baseurl&quot;)%20&amp;%20&quot;OpportunitySearch.aspx&quot;%20%>">Opportunity Search</a><br />
0
OMC2000Commented:
ups, you cannot use servers side code inside ASP.NET tags. You could assign value to the property
NavigateUrl  of OpportunitySearchLink like the following


<%
OpportunitySearchLink.NavigateUrl = RosReg.ASPZ.Common.WebRoot + "/OpportunitySearch.aspx";
%>
<asp:HyperLink ID="OpportunitySearchLink" runat="server"
                            NavigateUrl=''>Opportunity Search</asp:HyperLink><br />
0
OMC2000Commented:
sorry like this:

<%
OpportunitySearchLink.NavigateUrl = ConfigurationManager.AppSettings("baseurl")+ "/OpportunitySearch.aspx";
%>
<asp:HyperLink ID="OpportunitySearchLink" runat="server"
                            NavigateUrl=''>Opportunity Search</asp:HyperLink><br />
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.