How to navigate to another web form that resides in the same server - using HREF with C#, ASP.NET


We're upgrading our web applications written with ASP.NET, C#, from VS2003 to VS2010.

Assumed we created 2 projects, named PROJ_1 and PROJ_2; each resides inside its own folder (each is an application) under wwwroot.

Also assumed, we created web form FORM_1 in PROJ_1 and FORM_2 in PROJ_2.

In VS2003, inside HTML code of FORM_1/ PROJ_1, we can write like this for a link:
href = "../PROJ_2/FORM_2.aspx"
When the user clicks on the link, FORM_2 inside PROJ_2 is displayed.

In VS2010, it does not work. When we click on the link, error "File not found" occurred.

If you've any idea about this, please help.

Thanks a lot,

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.

Kumaraswamy RCommented:
try bellow example

var _basePath = '';
var _pagePath = '/Admin/login.aspx';

location.href = _basePath + _pagePath;


window.location.href =  _basePath + _pagePath;
somitsAuthor Commented:
Hi rkworlds:

Thanks a lot for replying.

The code I need is the HTML code. We're using Visual Studio 2010.

Actually, the "href = ..." code is in the source of .aspx file of a web form.

Can we use location.href and window.location.href inb HTML code?

Thanks a lot,

Todd GerbertIT ConsultantCommented:
Whether you write your code with Visual Studio 2003, 2010, Notepad, or a pen & paper is mostly irrelevant; your code runs on the server, what's significant is the web server, it's software & configuration, etc (not the version of Visual Studio you are using).

Having said that, I would guess that you're starting your project from Visual Studio by pressing F5 - in which case your web application is running locally (i.e. not on the web server), inside of Visual Studio's mini-webserver (called Cassini, I believe), and since the tiny web server built into Visual Studio only ever has one application configured at a time, references to ..\someOtherApp fail.

Your application needs to be deployed to a web server; you can deploy it to your local workstation's IIS and then use Visual Studio to open the web site http://localhost/yourApp - this way it will run in your PCs IIS.

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
.NET Programming

From novice to tech pro — start learning today.