ASP.NET relative path is wrong in Visual Studio - asp.net

I am using relative paths in my ASP.NET project, because I am using friendly URLs.
For instance, I am pointing to my pages like this: "/myPage.aspx".
When I implement this on my web server it's working well, but when I debug it in Visual Studio, it's linking like this:
http://localhost:xxxx/myPage.aspx (which obviously doesn't exist)
Instead of this:
http://localhost:xxxx/MyProjectName/myPage.aspx
It seems like Visual Studio is going all the way up until the Visual Studio folder, instead of stopping at the project's folder name.
How can I resolve this in Visual Studio? I think there should be something in the Solution's Property page, but I am not finding it. I am using Visual Studio 2010.
I prefer to debug in Visual Studio instead of IIS. I know how to make this work in IIS.

Visual Studio opens a port at random and sometimes you don't need a project name! You can create a vpath in IIS or in Visual Studio 2010, right click your project and choose Properties! There you can set your development server instead of IIS, and you can also set the MyProjectName as well!
Note: you'll have to set the Virtual Path to "/". This way the root will always point to the project's root folder.

Related

How do you allow parent paths in Visual Studio 2013?

I am converting a classic ASP site to a Visual Studio 2013 MVC project. When I run the classic ASP code inside of the Visual Studio 2013 debugger I get an error message:
Active Server Pages error 'ASP 0131'
Disallowed Parent Path
The question is: how can I enable parent paths in the VS2013 debugger?
FYI - This is not IISExpress and enabling parent paths is different.
I discovered the answer myself. Here is how I did it.
I opened Task Manager and saw that Visual Studio was running
processes of IISExpress for the web server functionality.
I clicked on Start and entered IISExpress to find out where it was installed. To my surprise, but an obvious choice, it was located in documents.
I opened the C:\Users\Mike\Documents\IISExpress\config folder then
opened Notepad as an administrator.
I then opened the applicationhost.config file and under the <system.webServer> element there is an <asp> element. I modified it to read. <asp scriptErrorSentToBrowser="true" enableParentPaths="true">
I then opened by MVC solution and ran the Classic ASP program without any
problems. Everything works!
I have Visual Studio 2015 and I had to do something else.
Right-click on the IIS Express icon in your tray while the application is running, and select Show All Applications.
Click on the application you want to manage. You'll see the location of the IIS Express server config file in the details section below.
Edit it as administrator and add enableParentPaths="true" to the asp XML element (under system.webServer), as in the Mike G's answer.
For me, the config file was located in SolutionDir\.vs\config\applicationhost.config.

How to make asp.net app run with visual studio server instead of IIS?

I have downloaded this blog engine
https://github.com/lelandrichardson/MiniBlog
I cannot run it within Visual Studio because it wants IIS : how to change this ?
If your project doesn't load in Visual Studio (it is greyed out), you need to manually edit the project file (MiniBlog.csproj) in a text editor. You just need to look for the UseIIS tag, and change its value to False:
<UseIIS>False</UseIIS>
When you do the above, Visual Studio should be able to load the project. It should now default to the Visual Studio web server.
Once you are able to load the project in Visual Studio, you can choose another web server, if you wish. You just need to right-click on the project in the tree view and then select Properties. From there, if you open the Web tab, you can choose the legacy Visual Studio Web Development Server, IIS Express (you may need to install this), or the Server version of IIS.
Just a note - I was unable to actually build the project that you linked to. There appear to be missing dlls, but that is out of the scope of this question.
try to add IIS Express 7.5 for visual studio http://www.microsoft.com/en-us/download/details.aspx?id=1038

Debug asp.net without Visual Studio

Is there any way I can debug asp.net application without Visual Studio. I mean I have all aspx and .cs files in the folder but the system doesn't have Visual Studion installed in it. Is there any way I can debug it via breakpoints?
It's not going to be easy but .net does have a command like debugger:
http://msdn.microsoft.com/en-us/library/ms229861%28v=vs.80%29.aspx
You would need to attach it to IIS or whichever process is hosting your site and I don't think it's easy to add the breakpoints, but it would do the trick.
However, the simpler option would probably be to get Visual Studio Express edition, it's free and does let you debug stuff.
I've no idea if it's possible to create breakpoints and such without visual studio, but you could perform basic debugging by adding code to the existing files that outputs whatever you need (variable values, caught exception messages?) to a log file?

Problems with 'Publish Web Site' on Visual Studio 2010

Recently I've upgraded from Visual Studio 2008 to Visual Studio 2010, however I'm having various problems when uploading my compiled web site to the live area. I'm doing exactly the same as I would have done with Visual Studio 2008, however, now I receive errors such as:
{filename}.aspx is not a pre-compiled file
masterpage.master does not exist
All these errors don't make sense. Has anyone encountered these problems before, and was a solution ever found?
Try run the Clean Solution command from the Build menu on your solution.
Try diagnosing by publishing to a brand new IIS location. Perhaps there are files from your VS2008 build that aren't being overwritten by your VS2010 build.
Are all the files present in the bin directory as you'd expect?
Is there an PrecompiledAppConfig.config file in the root?
You can run the Clean command by selecting Build -> Batch Build. You will see the options Build, Rebuild, and Clean in the dialog box.
The web site does not have to be created in IIS in order to use the Batch Build dialog.
Hope this helps,
Rick
you probably have not created an application or virtual directory on your server.
use IIS Manager to create it

What to write in "Web location" field when starting an "New website" in Visual Studio 2010?

I want a website to be deployed automatically to a local IIS (built in Windows XP Pro SP3), avoiding VisualStudio-built-in server if possible. I'd like development source files to be stored in a project folder outside wwwroot (I wouldn't mind built files to be copied to wwwroot each time I press F5).
I don't store my projects inside default directories inside "My documents". What should I specify as in "Web location" when starting an "New website" in Visual Studio 2010? A deployment path in wwwroot, a folder where I'd like to save my project, or something else?
I want the website to be a part of a complex solution in VS 2010, also icludinc a class libray project, a WinForms application project, a Windows Service project and a common Entitity Framework data model.
Consider using the Publish option in the Build menu to deploy your files to the actual IIS Server, wherever that is located. Undoubtedly you feel that you have strong reasons for doing it the way you described, but:
There is no practical way to install a current version of IIS on Windows XP
Putting development files directly into the wwwroot directory of an IIS Server makes me nervous
The web server that comes with Visual Studio is good enough for development, and is designed specifically for that purpose.

Resources