Visual Studio ASP.NET MVC project: setting the start URL - asp.net-mvc

Consider an ASP.NET MVC 2 project with VS 2010. The goal is to set the 'start URL' on run/debug using VS's built-in Cassini web server.
Entering the URL as I want to be loaded, in the typical & valid format, controller/action, VS 2010 gives this exception.
Tried Remedies:
starting the URL with and without a slash
ending the URL with and without a slash
Question: How can you specify the start URL for an MVC 2 project?
Technologies:
Visual Studio 2010
ASP.NET MVC 2
Resolution: I was using the wrong field in the startup options. What was needed was the "Specific Page" field with the relative URL, and not Start URL.

Start URL has to be a fully qualified URL and is not really used that often. It's meant for testing web services by opening a page that will call into the service, but isn't part of the application itself.
If you're just looking to start on a certain page of your application, which it sounds like you want, then use the "Specific Page" field, and enter your relative URL.
Here's the doc page on project start options.

Use Start Page \ Specific Page -- NOT START URL -- and specify your URL without a slash.
That oughta do it for you.

I was looking for a similar solution for VS2015. If anyone is reading this and you just want to run/debug via Visual Studio 2015 without having to attach to process and you're happy to run through Local IIS instead of Cassini or IIS Express, you can set a config like this:

I have just removed the files with .user extension in my web project and the solution map and the problem is solved now. Try to close your solution in Visual Studio and take a backup of files you "remove"first.

Related

ASP.NET 5 MVC – How do I change the starting URL for an Intranet-hosted application

I require my Intranet-based project to start up in the following place with the URL: http://localhost:8082/CMWebApp
However when I run it in debug mode in Visual Studio 2015 via IIS Express or from within IIS itself it appears as:
http://localhost:8082/
I then have to type the CMWebApp bit myself onto the end of the URL in the Browser. Not a complicated thing to do I wouldn’t have thought but I have not been able to configure the Project to do this. Can anyone advise how to do so please?
Many thanks
For asp.net-5 web project here it is:
Right click on the Project -> Properties -> Debug then set the "Launch URL"
On the server environment it is not a ASP.NET 5 issue, but more of a hosting environment change. In IIS, you need to define the folder you are hosting your app as a Virtual Application under the root site and deploy to it using the deployment tool of your choice, MSDeploy I presume.

Why does Visual Studio 2012 create content folders for Web API projects?

I find this odd given that a Web API project should really be a view-less MVC 4 Web API based project. Is there any reason for these projects to contain these files by default? I would like to eliminate them all (*.js, *.css, etc.), any reason not to?
These files are included to build the "normal browser" view, this is the page wich you see if you navigate to your host without the "/api" call in your url
You could remove these files if you don't want to use their functionality.

Unable to start debugging on the web server. The web server could not find the requested resource

I'm having this error trying to debug my ASP.NET MVC app. I've set the app to "Use Local IIS Web server", and selected ASP.NET as the debugger. Running the site without debugging works just fine, but when I try to debug, I got this error:
Unable to start debugging on the web server. The web server could not find the requested source.
I'm using Visual Web Developer 2008 Express Edition.
Does anyone know how to fix this error? Thank you.
For those encountering this with Visual-Studio 2012 and/or Windows 8 do the following.
You have to add .Net 3.5 (or 4.5) to your Turn Windows Features on or off window. You get to it via :
Control Panel -> Programs -> Turn Windows Features on or off
Click the Asp.Net 3.5 and the Asp.Net 4.5 check box in the IIS > WWW Service > Application Development Features folder.
Go to your web project's properties, then the "web" tab, then make sure that you're using the Visual Studio Development Server and not Local IIS or the custom webserver. I'm on VS2010 with Win7 and another developer was developing using a custom webserver URL and not the VS Dev Server
Sounds like you are trying to develop on IIS and not iis express or development server. If you are using asp.net mvc 4, make sure that the Application Pool is framework 4. If not just make sure that your app pool it matches your asp.net mvc version.
I had the same problem, and i fixed this way:
Go to IIS Manager -> Go to the site -> Error Pages -> Actions: edit feature settings.. -> Make sure you checked "detailed errors for local requests and custom error pages for remote requests".
IF you are using IIS6 and did the add mapping for .* in IIS trick to get MVC working, when you added the .* handler to iisapi.dll you forgot to uncheck the "check the file exists" check box.
Also, be sure that the URL you're configuring in Visual Studio matches your Host Headers (Edit Bindings) in IIS. This tripped me up for about an hour this morning before I realized my very stupid error.
Having maxRequestLength or maxAllowedContentLength set to a ridiculously large or small value will also trigger this error.
What i did, was just type the IP address in the web tab instead of "localhost"
This happened to me today. Turned out to be that the default website was stopped in iis. I had been working on a second website that didn't use it for a long time. Simple fix but took me a while to see it!
The root cause for this error can often be that the Windows Service W3SVC is not started. Check that this service in Windows Services console (services.msc) is started. In IIS you will now see the the Start icon is greyed out. This means that the W3SVC service is running.

Best way to deploy an ASP.NET MVC app on IIS 7 / Server 2008?

So far, the only successful strategy I've been able to get by with is the following:
Configure YOURAPP.Web to "Use Local IIS Web Server" and set "Project Url" = http://localhost/yourapp.web
Click "Create Virtual Directory"
In IIS Manager ensure that "Classic .NET App Pool" is selected
Add wildcard mapping * named "ASP.NET-MVC" that points to IsapiModule
BUT I don't really like the idea of having the full ASP.NET pipeline invoked when requesting any resource (javascript file, stylesheet, image, etc...) which is exactly what happens with the wildcard mapping.
So is there a way around this?
Is there a better method to running mvc apps on IIS 7?
I'm definitely open to suggestions as I'm not all that satisfied with what I got so far.
Thanks - wg
Make sure IIS7's "Managed pipeline mode" is set to "Integrated". That has been the single most important thing to do (for me) to get my MVC app running smoothly on IIS7.
Here's a good blog post too.
When developing the app, I have had no issues using the "Visual Studio Development Server" for running the app.
Assuming that all of your CSS/JS/image files reside in the Content directory, you could add an ignore route.
routes.IgnoreRoute("Content/{*wildcard}");
This will prevent any requests to the content directory being handled by MVC.
IIS7 is designed to take all requests and push off the static file stuff efficently. I wouldn't worry about it in the same way one worries about wildcard mappings on IIS6. There is no "load ASP.NET pipeline" penalty because IIS7 is a mean honking ASP.NET pipeline all the time.

Disable Visual Studio Web Server Directory Browsing

I'm using Visual Studio's built in web server to test and EPiServer applicaiton. When I have the app running in IIS, if I hit the root of the virtual directory, EPiServer will take over and server the defaul page to me. Using the Visual Studion server (which I am doing for license reasons with the SDK), it always gives me the 'Directory Listing' view of my site. Does anyone know how to configure this web server to not allow the directory listing/browsing?
Additional Information:
This problme only seems to effect the root of the visual studion web server (i'll call it cassini from here on in). As an example, if I run a site from localhost:6666, then what I will find is that localhost:6666/en/ will work just fine and the EPiServer VPP will know what it is doing. If I use localhost:6666/, then the VPP never kicks in (or so it seams). It seems to me that when the root of cassini is hit, it checks to see if the page exists (which it does not as I have no default). If it decides that the page does not exist, then it serves up the directory listing, rather than 404. The first thing to do for me is to dispable directory browsing in cassini, then look at why the VPP is not being actioned correctly.
So I suppose the base of the question is: Is there a way to modify these settins in Cassini when it is Visual Studio starting everything off?
(EPiServer may be a red herring, but just in case, it's CMS version 5)
Further Update
I managed to get hold of the source for Cassini 3.5 and gave that a whirl. 3.5 works just fine and behaves like IIS in this instance. I.e. the lack of default document does not lead to a Directory listing, rather if allows the HTTP handlers to kick in and then EPiServer does the rest! So the question is, can I achieve the same in Visual Studios effort at a web server?
Make sure you have a ~/Default.aspx file. It won't render, but it's needed in cassini for the virtual path providers to get a chance to handle the request for '/'.
Of course, if you make it anyway you might as well use it for the start page :-)
Even if you could get the server to not show the directory listing, could you get EPiServer to take over?
EDIT: From comments
The fact that it works with /en/ makes me think this is something that Microsoft could fix. I suggest you ask the vendor if they have a workaround. If they do not, then please create a suggestion at http://connect.microsoft.com/visualstudio/. Be sure to specify details about EPIServer, URL to the vendor, etc.
Be clear that it works with /en, but you want a setting permitting it to work at the root.
Once you create the suggestion, please edit your question to include the link to the suggestion you create. That way, others reading your question can vote on how important they think this is.
The EpiServer part confuses me. However, if you are asking how to set the default page for the VS development server (based on the Cassini code), you're expected to do that in the project properties (right click on web project), Web, Start Action, Specific Page, foo.aspx.
I suspect the cassini/VS development server doesn't have a default page feature-- the source code for the cassini server (the ancestor of the VS development server) is on the web and you can check that and add a default page by building a custom version. And it doesn't have a very long list of other features that IIS has.
Which EPiServer version are you running?
Did you install it using EPiServer Manager?
There has always been some differences in the configuration between running the site at the root of a host name or as a (virtual) directory.
Check the site settings block in web.config and make sure you have a default.aspx at the project root.

Resources