When I hit debug (shift+F5) I want the launch route to be
localhost:XXXX/Controller/Action
Instead of
localhost:XXXX/Views/Controller/Action.cshtml
How do I do that?
By default, Visual Studio will often automatically attempt to go to the current page that is selected when debugging your application (thus attempting to access your current .cshtml page).
Setting a Default Start Action
If you want to set a particular Action or URL to be launched when running your application, you can do so through the following steps :
Right-click your Project within the Solution Explorer.
Choose Properties.
Select the Web tab on the left-hand side.
Under the Start Page section, define the Specific Page you would like to default to when the application is launched.
Save your changes.
Assuming your using Visual Studio 2015 or 2013: Project Properties -> Web (tab) -> check Start Url and enter in the desired URL.
Related
Is there an easy way to set the web application as the startup project and not have it change automatically? In the solution explorer I right click on the project and hit "Set as Startup Project" but if I end debugging and try to start again, VS tries to set whatever page I'm working on as the startup project. Am I missing something or am I just being picky?
Thanks in advance.
Set web project as startup:
Right click the solution, under common properties > startup project, ensure the correct startup project is selected:
To set a specific page within the project:
Right click on the project, select 'Web' then under 'Start Action' you can set exactly what page you would like to start. If you want to load a specific page, select the 'Start URL' option and enter a URL. For example in MVC use /Controller/Action
set as start page in vs2012
Right click the Project
Select Properties
Click on Web
Select Specified Page
Specifies the controller/action you want to always start. Example: Home/Index
Enjoy!
To put it simple, whenever i run (debug) my MVC project while focusing a View (in the editor window) on Visual Studio 2012, the web page shown on the browser is the View itself rather than the actual landing page.
For example:
If my usual landing page is the following:
http://localhost:53338/
Then if i'm focusing the 'Add' View and I Run my project, it sends me here:
http://localhost:53338/Views/Products/Add.cshtml
Any idea how to 'fix' this?
Thanks in advance
Your web debug configurations are set to run the "Current Page".
Here are the steps on how to solve it:
Go to the project's Properties (Right-Click on the project -> Click on Properties).
Go to the Web tab.
Select the Start URL radio button and leave the address text-box blank.
In the Project URL type: http://localhost:[portNumber]/
Good luck
I'm sure this is a simple misunderstanding but I'm trying to change the default browser in Visual Studio 2010 from Firefox (my machine's default) to IE so that VS will stop debugging when the window closes.
Based on ScottGu's post on the subject, I'm expecting a "Browse with..." option when I right-click on an aspx page in my MVC app; but there's no such option.
Also (possibly unrelated), when trying to launch the ASP.Net Configuration, the Cassini Development Server starts, but no browser instance launches. Starting to get very frustrated!
Asp.net MVC doesn't let you do this
You can only see "Browse with..." when you right click on the Default.aspx on app's root. Otherwise it's just not there.
This menu option obviously isn't stupid and doesn't let you browse a particular view, because it's not up to the browser to request a particular view, but up to a controller that may display some (or any) view... So Visual studio doesn't give you this option on your views.
I suppose it would be best if you've changed your default browser on your development machine.
In ASP.NET MVC 1 projects, you have to right click Default.aspx to get the "Browse with..." option.
However, ASP.NET MVC 2 projects do not have a Default.aspx. The best way to change your default browser is to create a standard ASP.NET project and set the default browser using that.
I'm building an MVC 2 project and encountered this issue. I just created a Default.aspx web form in the root folder, used the Browse With... menu it exposed to set my browser for this particular project to IE, then deleted the Default.aspx. Kind of a pain, but you only (should need to) do it once.
You can add an app_offline.html file to your MVC3 app. This is useful, because if you rename it to app_offline.htm and deploy it, it will cause IIS to deny all requests to the app (and will return the content of the app_offline.htm(l) file).
If you have one of these, you can right-click it to get the browse with option. In case you want to test out with different browsers & window sizes from VS, without a plugin.
Right now it always goes to default.aspx that subsequently opens the default controller but I would like to go directly to the controller I am editing when I hit the debug button.
Right click on the Web Site in Visual studio and select Property Pages. The Start Options section gives you flexibility as to which page loads first. You can choose and set the Start URL option to something like http://localhost:1324/Home/Index to force debugging sessions to default to the HomeController's Index action.
This requires two things to be true:
1234 is a static port used by the Cassini web server when debugging your pages (you can change this behavior by pressing F4 on the web site's project and setting the Use dynamic ports setting to false and the Port number field to a port of your choosing.
The Web Site automatically starts up when you run the application from Visual Studio. Make sure it is by selecting the Property context menu item from the Solution's right click menu and editing the Common Properties -> Startup Project settings.
Alternatively, you can use the Use Current Page setting of the Start Options dialog. Developer beware though, as I'm not sure how MVC-aware this option is.
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.