"Browse with..." option not available on ASP.Net MVC Project - asp.net-mvc

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.

Related

I can't display/browser my images in Virtual Directory in IIS

From a remote server with Microsoft Server 2016 where I am admin, I publish my ASP.NET Core MVC web app in Visual Studio 2019 via IIS Server 2016 as a Website called "demo".
dotnet-hosting-3.0.2-win, dot-net-3.0.102 sdk bundler and urlrewrite2 are installed.
The project is just the simplest "Hello" demo, it works.
Then in I add a Virtual Directory to my website in order to display images from a shared folder.
When I create this Directory, I tried both methods:
- "Connect as" / my user log. "Test settings" gives an OK icon.
- "Application user" + Edit Permissions / Security / Edit / Add / IUSR
Once my Directory added, I can see the content of it in Content View panel, 2 images.
I also tried to add the Directory to wwwroot of my website.
I precise that in Features View panel, Directory Browsing is enabled.
I also tried to access my images via code.
This is what I get:
I am pretty new with deployment, still I have read a lot of documentation, but I can't make it work. What did I miss? Is there something to do with a webconfig in IIS?
I am not expert but as per my little understanding of IIS and ASP.NET MVC, please try following.
Click on your "demo" site in iis manager and on the right side, under "actions" pane click browse. And then navigate to your images folder from browser.
Also, you can only see individual files under this directory and not a list of files.
You can access individual file using the spcefic URL, for example http://localhost/images/image1.jpg
If you hit "http://localhost/images" this URL, IIS will try to find a controller or action method by this name.
Lost my problem thanks to this link:
Virtual directory inside of ASP.NET Core app in IIS
The big picture I get is Net Core is just not designed by default for IIS/Virtual Directory, but you can get your stuff by modifying the applicationHost.config of IIS manager.
Supposing your Virtual Directory is called "bilder" in the website "democore", you would write this at the end of your applicationHost.config:
Hope it will help.

ASP MVC 2 with asp.net development server won't load default controller & action for an empty route

This used to work fine, but recently it refuse to load the default page for an empty route, instead it lists directory contents.
for example
http://localhost:1234/ should take me to the same page as http://localhost:1234/Home/Index assuming global.asax hasn't been modified, however recently it just takes me to "Directory List -- /" and lists out the content of the project folder.
This is using the ASP.NET Development Server. The sites work fine when deployed into IIS on a server.
Does anybody have any ideas, this is really annoying!
I would check the project settings like suggested on this other question:
Launching my debug MVC3 application opens a specific .cshtml file in the browser
Through trial and error I've determined that this is caused by the IBM RTC plug-in, when disabled it works normally.
I find this very surprising, but I've double checked and it is definitely that!

How can I make visual studio open the controller Im currently on be default when debugging?

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.

Page Not Found error in ASP.NET MVC application on live server

I wrote a simple file upload application using ASP.NET MVC. I tested it successfully on my development machine, but when I attempt to use it on my live server any action I try results in a Page Not Found page.
With my hosting provider (reliablesite.net), I needed to specifically upload the System.Web.Mvc dll to my bin folder, so it is possible I am missing an assembly or something...but I should be getting a hard error like this one if that is the case:
link to live site, try clicking the about or the upload etc to see what I am talking about.
Thanks!
This is happening because of the IIS setting "Check if file exists" for the web project.
What I had to do for one of my web projects was create a new extension for my web app. So I go to INETMGR > WebApp > Properties > Directory Tab > Configuration Button > Mappings Tab > Add Button and set the Executable to aspnet_isapi.dll, set Extension to ".*" and un-check "Check that file exists".
It looks like an IIS configuration issue. Extensionless routing's possible, but it can be a bit of pain to get running.
Phil Haack has an article on getting MVC apps running on IIS 6 here - I don't know how much access you'll have to the IIS console if it's a shared environment, so it may or may not be useful.

ASP.NET MVC and IIS 5

What is the best way to get hosting of an ASP.NET MVC application to work on IIS 5 (6 or 7). When I tried to publish my ASP.NET MVC application, all I seemed to get is 404 errors. I've done a bit of googleing and have found a couple of solutions, but neither seem super elegant, and I worry if they will be unusable once I come to use a shared hosting environment for the application.
Solution 1
Right-click your application virtual directory on inetmgr.exe.
Properties->Virtual Directory Tab-> Configuration.
Add a new mapping extension. The extension should be .*, which will be
mapped to the Executable
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,
or the appropriate location on your
computer (you can simply copy this
from the mapping for .aspx files). On
the mapping uncheck "check that file
exists".
3 X OK and you're good to go.
If you want, you can apply this setting to all your web sites. In
step1, click on the "Default Web Site"
node instead of your own virtual
directory, and in step 2 go to the
"Home Directory" tab. The rest is the
same.
It seems a tad hacky to route everything through ASP.NET.
Solutions 2
Edit the MVC routing to contain .mvc in the URL and then follow the steps in solution 1 based around this extension. Edit: The original image link was lost, but here it is from Google's Cache:
Answer is here
If *.mvc extension is not registered
to the hosting , it will give 404
exception. The working way of hosting
MVC apps in that case is to modify
global.asax routing caluse in the
following way.
routes.Add(new
Route("{controller}.mvc.aspx/{action}",
new MvcRouteHandler()) {
Defaults = new RouteValueDictionary (new{ controller
= "YourController"} ) });
In this way all your controller
request will end up in *.mvc.aspx,
which is recognized by your hosting.
And as the MVC dlls are copied into
your local bin , no special setttings
need to be done for it.
I think either way you'll have to do Solution 1.
Consider the HTTP Request pipeline.
A request comes into IIS.
IIS checks port/host header to see if it has a web site set up to capture requests for that host header/port.
IIS investigates the file extension of the request (.php, .asp, .aspx) and hands it off to an ISAPI that can handle that type of request.
Only at this point does ASP.NET (or a PHP runtime) kick in. If IIS does't have that mapping then it'll never hand off the request to the ASP.NET runtime and the request will never reach your code. That's why you need that glob (*) mapping to the ASP.NET ISAPI.
ASP.NET MVC framework urls often end with no file extension at all. If you want these requests to get handled by ASP.NET (or some other runtime) you have to map all requests regardless of the file extension to that ISAPI (ie. aspnet_isapi.dll).
This is often also done for HttpHandlers that need to serve off media like .jpg, .gif. For the handler to be hit it needs to get mapped to your code even though .jpg isn't a "normal" ASP.NET file extension.
HTH,
Tyler
Run:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll -i
This will reset IIS registry settings for aspnet user.
Create the virtual directory:
1. Right click on the directory you want to convert
select Properties
under Directory, select Create.
under Configuration, select Add.
for Executable insert:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
for Extension insert: .*
uncheck “Check that file exists”
under Documents add entry point file, ie: Default.htm, index.htm, Global.asax
under Directory Settings
select Edit...
select Anonymous access
uncheck Allow IIS to control password
uncheck Basic authentication
uncheck Integrated Windows authentication
under ASP.NET, make sure version = v4.0.30319
TAKE NOTE of User Name ie: IUSR_AVSJ82S
Set sharing permission of physical directory:
In windows explorer, go to the physical directory that was converted to a virtual directory.
Right click the directory name
select properties
under security tab, select Add
enter the IIS User name ie: IUSR_AVSJ82S click check name.
click OK
set permissions to Read and Write.
FYI:On server 2003 (developing an app that had to connect to the RPS), it didnt' allow me to add the extension .*, I used the alternate solution modifying the route clause, and that
worked.
Have you tried adding .aspx to the end of the controller name?
It worked for Stack Overflow question Where can I get ASP.NET MVC hosting?.

Resources