Back in the days of web forms you used to be able to right click a web page in your project, select 'Set as start page' and know with confidence when you started the web app it would automatically navigate to the selected default page. In these new-ish MVC days, with routing and changes to the iisexpress application.config there seem to be a number of different things that will effect what the default URL of a web application is. Is there an easy way of finding it without having to navigate into the Global.asax.cs\Routing\config to try and figure it out?
p.s. I'm aware that after starting a web site from the IDE, hovering over the iisexpress icon in the system tray gives the debug location in iisexpress but it doesn't seem to give the default controller route!
You can install RouteDebugger, it will add a section below your page, you will see the matching default route in the bottom of your home page.
Related
I have developed an asmx web service in C#. I have also hosted this on IIS. Just a quick question about the debugging. Do I have to always right click and select browse under Context View.
Or can I open up a browser window and navigate to the asmx url on localhost. If not how do I make it work only with browser action and not always inetmgr.
I didn’t fully get your point. What we have to do might add a URL shortcut to the browser favorites.
Besides, to debug the ASMX file(XML web service) quickly, IIS Express that integrated into VS is enough. Just add a breakpoint to the web method then Press F5 in VS, and then click the IIS Express icon in the left bottom.
Moreover, in the common property page of the solution, tick the Current Selection option of the startup project. this will open the Web.asmx file automatically when debugging. it is also a quick shortcut for debugging.
Feel free to let me know if there is anything I can help with.
I am trying to deploy my first ASP.NET application on a server running IIS 7. But I always get an error 404 when trying to open the page. I thought it might be a start page issue, so I entered a direct URL to a .aspx file inside the wwwroot folder, but that got me another 404. Next step was to set a start page in the IIS Manager to a certain .aspx file, which made the page open, but the URL shown didn't include the specific page, and I didn't see my bootstrap navbar (just links that should be inside it) nor my Infragistics components. (To give context, we just upgraded the server to .NET 4.5 this morning, but all other ASP.NET websites in the same or other application pools still work perfectly!).
I then enabled the option to see folder contents in the browser; opening the website then showed me all the files that were supposedly not found, but clicking on them gave me 404 again. For testing purposes I put a .html inside the main folder: that one I could click and open, as well as *.css files or images in subfolders. But as I said above: ASP.NET is installed and working for all the other websites. I checked the MIME things, there is nothing for ASP related files, but neither is there in the working projects. The handler mappings seem to be correct as well.
So what could the reason for this be? I am totally unacquainted with IIS, so I lack any ideas beyond simple googling :/ My guess would be something permission-related (the app pool it's currently in is using pipeline mode: classic; but again, the same as the working stuff) or another dynamic content option I missed. Or - since as soon as I manually define a start page to be one of the .aspx files, I see at least something - it could be related to extensionless URL's? When I manually enter
myservername\myappname\StartPage.aspx
the browser at least shows
myservername\myappname\StartPage
instead. But I can't seem to find an option to change this. Any help is greatly appreciated!
I ran into this issue when I first started working with ASP.NET. I spent hours scratching my head trying to figure out what was the problem. After a fair bit of research this is what solved my problem. I added the flowing code in the web.config file.
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"></modules>
</system.webServer>
I need to restart my mvc4 web application programmatically. But System.Web.HttpRuntime.UnloadAppDomain() doesn't work.
What is the best way to restart asp.net mvc application? Please mind that changing web.config content or folder names doesn't solve my problem.
this code work for me. just call it to reload application.
System.Web.HttpRuntime.UnloadAppDomain();
More info
This method will just unload our application. If you just put this method in an ASP.NET web button you are totally done. So when will our application reloaded? Actually if you click your button it will first launch our method and unload application. Further on the web page we are on at that moment will be reloaded as well, because we just clicked a button and the web page should refresh. After launching our method the page refresh process will cause our application to reload as well.
EDIT - After looking at comment on OutputCache in the question, You can invalidate OutputCache programmatically, Check this out
If still you want to Restart IIS or AppPool then you can follow these resources -
Programmatically start/Stop a Website in IIS
Restart IIS7 in C# using iisreset.exe and
System.Diagnostics.Process
Recycle ApplicationPool for IIS in C#
Is it possible in ASP.NET MVC to display a downtime page when publishing a project out to a server?
Right now, if I hit the page while I am publishing I get an error:
Could not load type "App.MvcApplication"
It would be awesome if we could setup a downtime page so that users know to come back at a later time, instead of thinking that the app is busted.
You could add an app_offline.htm page to your application root, traffic will be redirected to that page until you remove or rename it.
More info
Scott Gu's App_Offline.htm
App_Offline.htm and working around the "IE Friendly Errors" feature
Will app_offline.htm stop current requests or just new requests?
An alternative to doing this in the application is to have IIS sort this out for you.
Application Initialization Module gives this feature, and also allows you to run warm-up scripts.
When I click WSAT (ASP.NET WebSite Administration Tool) icon, it doesn't open automatically, but I have to click on the dev server icon on system tray and open it up and it brings me WSAT with only a message:
An error was encountered. Please return to the previous page and try again.
Maybe this has to do with the URL it opens:
http://localhost:52785/asp.netwebadminfiles
I remember to see a longer URL sometime, like a URL having a query-string with "filepath" or "filedir" or something like this.
Can someone help me with this or indicate a tutorial to create my own user management on an MVC application?
Since I had the same problem, here is what solved it for me:
first you need to run the project, and then run the website admin tool. That way it should work without problem, at least for me it did.