How can I make visual studio open the controller Im currently on be default when debugging? - asp.net-mvc

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.

Related

Visual Studio MVC debug launch route

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.

Issue running MVC project while editing a View

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

opening default browser with delphi at specific position

I want to open a web page at default browser at a specific position and also open another webpages at that one, not new task of that browser. maybe user opens new task of that browser but by clicking a button in my delphi program the selected web page have to open at first one. is that possible? my company wants me to program such thing BUT I do not know how to do. I really appricate any help. thanks.
There are instructions here to open the default browser, but you may even be able to "run" a url, as you can from the Windows run command. You then need to retain the handle of that process so that you can do something with it.
To open a web page at a particular point you would ideally use a named anchor in the page, ie, the bit after a hash: http://www.w3schools.com/TAGS/tryit.asp?filename=tryhtml_a_name If you don't have control of the page and there are no named anchors you could try scrolling: How to scroll the scrollbar in external application via WinAPI?

Where is this port number http://localhost:52432/ specified when running an ASP.NET MVC app?

I'm playing around with ASP.NET MVC and I just loaded up an empty project and ran it and the URL in my browser is http://localhost:52432/. Where is the 52432 port number specified?
Thanks in advance for your help, I'm going to start researching this question right now.
in your project file
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>1424</DevelopmentServerPort>
The setting is stored in your project file which is XML, to access the setting from the UI, right click on your project in the solution explorer and choose properties. In the properties dialog on the left side there is a tab selector, choose Web.
In the Web properties in the Servers section you will see a radio button for 'Use Development Server' and by default it will probably be set to Auto-Assign port, you can change the setting there and choose an explicit port or change to IIS.
Again - Project-Properties-Web

"Browse with..." option not available on ASP.Net MVC Project

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.

Resources