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.
Related
We have a regular asp.net website. I started debugging several errors, so the website cannot be used (but is not down). Since the default page is not Default.aspx and users are used to going directly to Main.aspx, if anyone goes to http://network:1332/Main.aspx, the person should be redirected to Issues.htm.
Is there an easy to do this without having to alter Main.aspx or write any code? Maybe change web.config or some IIS 6 configuration?
I just don't want anyone to use the website even though the site is available for use.
Thanks.
If you have an ASP.NET web application site, and you place a text file
named "app_offline.htm" in the root of the site, all requests to that
website will redirect to that app_offline.htm file. Basically, if you
need to take an entire ASP.NET site offline, you can place some nice
message in that file.
https://forums.iis.net/t/1152788.aspx?Put+website+in+maintenance+mode
Be warned you too will be directed to the maintenance page, so if you're debugging in production this could make things more difficult.
You can use Url Rewrite Module to IIS. Then you will be able to define your rewrite rules in web.config or using IIS Manager. Check this : https://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
After building an MVC web application, I'm used to experiencing a slow load time for the very first web page that's accessed, and I know why this happens, but I'm also noticing that the load time is slow for the initial access of every single web page.
As an example, here are the load times for my home page under various conditions. The home page does not make any database calls:
Built project and loaded hope page (first web site hit, and first home page hit): 10.31 sec (expected)
Built project, loaded contact page (first web site hit), and then loaded home page (first home page hit): 757 ms (not expected)
All subsequent load times for home page (2nd, 3rd, 4th, etc. home page hits): 4 ms (expected)
I have reproduced these same results for all web pages, not just the home page. I.e., if you replace "home page" with "about us page" and "contact page" with "faq page" the load times will be nearly exactly the same as above.
These number are for my local environment, and if I push my project to the production environment, they skyrocket, and the initial load of every page is dozens of seconds.
What's interesting is that I can only remember this starting to happen a few days ago. For the last several months, from what I can remember, the initial web site load was always slow, but after that, all pages would load very quickly on their initial load.
What is causing the slow initial load time of every page?
The application pool needs time to build the libraries before it can begin processing them. This can be speed up by using some kind of script. It also depends on whether you're using a website or a web application project. A website for every page the very first hit is slow and each new page hit has an extra compile time. Web application projects are precompiled should be little faster, but the libraries still need to be loaded up. The more libraries and tools you have the worse this hit tends to be.
You could also looking for IIS Auto-Start feature and setup it on your server may help speed up the process. By default Application pool gets shutdown in case of user inactivity default value of 1740 mins. You can also disable idle TimeOut by setting to 0 can help a lot.
My best bet is using Application Initialization plugin to get better performance
http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-application-initialization
It is occured after I move my project from VS2017 to VS2019. I found the problem I guess. Every page is compiled once on first visit. Check publish options. You will see an option "Precompile During Publishing" Enable this option. Delete BIN and WIEWS folders. Copy folders from publish location (do not overwrite)
I am using ASP.NET MVC5 and Visual Studio 2015 for own web application. My application is deployed on the IIS 8.5 server. I have very slow performance during first loading of the each page. The next each request for the specific page is very fast. I think that this is due to compilation of the page. Please help me, how i can setup pre-compilation of the views during publishing process on the build server?
The question here is, how heavy are you pages, it sounds to me browser caching is making the pages faster on your second call. it dosnt to do anything with IIS. in IIS the first load is always slow once the project gets built the next requests will be quick.
so I suggest look at your view, optimize images and scripts and etc...
We use Razor Generator for this, it's a VS extension.
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 there any way to specify a permanent port for ASP.NET Configuration site (Web Site Administration Tool)?
I need to add a link to the ASP.NET Configuration site, but I can't due to the port changing each time it starts.
Its the port for ASP.NET Development server
http://msdn.microsoft.com/en-us/library/ms178109.aspx
I'm not sure that you can.
The Web Site Administration Tool isn't really meant to be "linked" to as such, it's a fairly powerful, unsecured application, that's only really meant to be run by a developer/admin.
The "Considerations" section of the documentation explain why:
The following sections provide some considerations for working with the Web Site Administration Tool.
Restarting the Application When Saving
Most changes to configuration settings that you make in the Web Site Administration Tool take effect immediately. This requires the Web site to which the change applies to be restarted. Because this will cause currently active sessions in the Web site to be lost, you should make configuration changes to a staged or development version of the Web site before publishing these changes to the production server.
Saving Your Settings
Most changes to configuration settings that you make in the Web Site Administration Tool take effect immediately. For settings for which the Web Site Administration Tool interface has a dedicated Save button, leaving the Web Site Administration Tool idle or allowing the Web Site Administration Tool to time out before you click Save will cause your configuration settings changes to be lost.
Time Out
As a security measure, the Web Site Administration Tool times out after a period of inactivity. Any settings that did not take effect immediately and were not saved will be lost. If the Web Site Administration Tool has timed out, close your browser, and then reopen the Web Site Administration Tool in a new window.
The Web Site Administration Tool manages only some of the configuration settings that are available to the Web site. Many other settings require direct modification of configuration files either manually, by using the MMC Snap-In for ASP.NET, or programmatically, by using the ASP.NET Configuration API.
From that you can see that this isn't something that's intended to be kept around.
That said, with a little bit of hacking around, you could probably shoot yourself in the foot achieve what you're after:
If you right click on the ASP.NET Development server task tray item for the admin tool, and select "Show Details", you can see that the virtual directory that the tool runs under is mapped to (something like):
C:\Windows\Microsoft.NET\Framework\v4.0.30319\asp.netwebadminfiles\
If you were to create (and secure) a virtual directory on your application mapped to that path, you might well be able to get this all up and running as you want.
As pseudocoder points out in his comment below, while going down the Virtual Directory route does "work", there are some limitations to the tool that, coupled with the security issues mean that you probably wouldn't want to use it going forward.
If you were to stick with the Development Server option, the tool won't respond to non-local requests, and once you've deployed the site to a proper web server (IIS) for users to access the Admin site won't be running anyway.
It would probably be better if you could explain why you want to use this permanently so we can advise you on some better options - for example the Membership, Profile and Role providers both provide nice APIs for managing user details that can be easily built into a custom admin area.
Tricky one, however I think to get this working correctly, you're going to have to spend some time doing something, and it's probably better for you in the long run to spend that time doing the right thing rather than hacking in the wrong option.
The Development server can be started from a command line, using a commands along the lines of:
call "C:\Program Files\Microsoft Visual Studio 9.0\vc\vcvarsall.bat"
"C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.exe" /port:3900 /path:"PATHSITE" /vpath:"PathSite"
The first line sets up the CMD instance to use the variables and path settings needed to run most of the Dev tooling
You'll want to change the path to the DevServer as appropriate for your environment (mine's in \10.0\ for example, and has a 2.0 and 4.0 version).
Armed with this information, you could do something along the lines of:
Add a link to your site to a page called /StartAdmin.aspx or similar.
In that page, you would then need to have the logic to:
Check through the running processes for the instance of the DevServer that was previously used to host the Admin site.
Close that process down.
Spool up another instance of the DevServer with a known port, pointing to the path for the WebAdmin Site.
Redirect the user to this new site.
All of which is possible, but it's not trivial, and you'll find you'll need to be doing odd things with the process your starting, and you'll need to be very careful you don't shut down the instance of the DevServer that's actually running your site by mistake.
However, this would probably take as long as it would to knock up a quick set of user admin screens, and you'd learn something more useful along the way*
* Which isn't to say that learning how to start and leave running a process isn't useful, it's more to say that I'm guessing its not what you're supposed to be learning at the moment, and you should probably be focusing on that ;)