Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pointing to root of web application

Status
Not open for further replies.

MeX2

Programmer
Jan 14, 2010
3
0
0
US
I have a web application using IIS 7.0 and VS 2008. In my HTML, I am referencing an image as so <a href="/test.aspx">Test</a>. When I launch the website in debug mode, the link is pointing to " when it should be " I want the root to be " but it is just being seen as " The physical path of my website is in "C:" and a virtual directory for this site exists in " Please help, I have not idea what is wrong. Thanks!
 
Code:
<a href="~/test.aspx">Test</a>
should do the trick

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Thanks Jason for responding. However, if I do that, I get . Think i may be leaving out important deatils: in the properties window of my project, I go to web and in Start Action I have chosen Specific Page as test.aspx. Under Servers, I have chosen Use IIS Web Server, Project Url as Apply Server settings to all users(sote in project file) is also checked in this section.



Thanks for you help!
 
I believe I have solved the issue. Thank you.
 
Jason's suggestion will work for a server control, if you are using a standard HTML anchor, try something like this:

<a href="<%=Request.ApplicationPath() %/test.aspx>Test</a>
 
that's why I love Spark! clean html without noisy server syntax. It's a shame you cannot plug other rendering engines into WebForms.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
You can control 99% of the html output with the current version of webforms (the only exceptions I can think of are the viewstate element but this can be "minified", and the id that is rendered for server elements), however the next version (ASP.NET 4) fixes these issues and will therefore up this percentage to 100% so I wouldn't be too concerned about an unrelated view engine.

Mark,

Darlington Web Design
Experts, Information, Ideas & Knowledge
ASP.NET Tips & Tricks
 
Spark is a response to tag soup. If webforms is used strictly as a html engine (like MS MVC) then <%%> is required for VeiewModel, looping, if/then, etc. With Spark server syntax looks like html. very easy to read. browse the docs for details on this.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top