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#
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 have one windows application developed in c# and one web application developed in asp.net and MVC. Now i want a mechanism like when i press button in windows application it should open this web application preferably in IIS it self so that my web application is viewed in browser. kindly help with this as my final year project is pending due to this
You just have to open the URL of the Web server.
See: How to open in default browser in C#
System.Diagnostics.Process.Start( "http://google.com" );
The way to do this is to first host your web app and provide it URL to the button click like
Response.Redirect("Your URL");
If use want to test this before having your web app hosted , You have to put both the project in one Solution and in Properties of it you need to set both the projects as startup project. No doubt your web app will also open but for time being you can ignore that window and can check whether the redirecting of URL is working.
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.
I have migrated 2 DLLs and an aspx page to an existing web application on a production server. The changes in the file do not show up when I run the web application.
I have restarted the web application, restarted the associated application pool, run iisreset, deleted the Temporary ASP.NET Files. The changes do not show.
I have created a new html file in the root of the application, but it returns a 404 File Not Found error.
In IIS, I right-click the web application and choose Explore just to make sure that I am in the correct directory. I am. I see my updated files there. I can view the text of the aspx page, and my changes are there. My test html file is there.
I have searched StackOverflow, implementing all of the prior solutions I have seen that have fixed other poster's questions. Is there anything else I can do to IIS, the file system, or anything else to get these changes to show?
It sounds like you are not hitting the website that you think you are. Check your bindings and host headers, maybe another site on the server is intercepting the request.
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.