Slow ASP.NET site when not providing a page name - asp.net

On my ASP.NET Site (.Net Framework 4.5) if a user provides a pagename such as http://staging.site.com/index.aspx the site loads as expected and the user can navigate around the entire site without issue.
If the user loads the site and than changes/visits a URL that redirects to the root http://staging.site.com/ with no page name, the first load hangs up for over a minute and than all requests thereafter are also slow.
The issue is only isolated to the users session. It does not affect other users.

Turns out we had enabled session variables to be used in our webapi classes. And the overhead of doing this was causing the server performance to decline significantly

Related

ASP.Net has very high server time

I have a 32-bit asp.net application running in IIS 7.5. I am having an issue with the pages.
Mentioned the issue below.
Open a page. Hit the database through some action in the page.
Open another page in another tab. Now, the second page doesn't respond till the first page responds. The second page has no database hits in page load. It's just plain HTML.
This happens with all the pages in the application. I am not sure if it is because of IIS or my application.
Do you have sessions enabled? If yes, all requests will be run serially. If you can, try to avoid using sessions or only enable it where you need it.

Intermittent ASP.NET WebForms routing error

I'm having a strange issue in my production website, which pops up somewhat consistently but with no known pattern.
My app consists of two websites, one of content which lists courses which the user can choose to apply, and the second under https where he actually applies (and pays) for it. I'm using routing in both of them (as per client's decision) and sometimes, when the user navigates from one to the other (a simple href link), upon 'arrival' on the https site, the routing with the course id gets lost and it redirects straight to the default.aspx page, and it crashes. I'm logging errors and I know for a fact that the loss of route (and routedata) is what's causing it (the route should be https://shop.courses.com/ins/{courseid}/ and it's throwing https://shop.courses.com/default.aspx).
In both cases I'm using WebForms, not MVC, and as mentioned, it's not constant. Both sites are hosted internally in a webfarm, running IIS 7.5

Session transfer between asp.net and asp works in soome cases and in some cases not

I transfer session from asp.net to classic asp.
I use MSSQL DB for it.
I have
SomeWebPage.aspx - this page is asp.net which save sesion, after it, it call by redirect
SessionTransfer.aspx -this page save sessions to DB and call by redirect
SessionTransfer.asp - this page load session from DB and cal by redirect
SomeWebPage.asp - this page doesn't need now about other pages, it just use session.
Problem is, that it works only if SomeWebPage.aspx, SessionTransfer.aspx, SessionTransfer.asp and SomeWebPage.asp are in same folder, or in same "web pages" folder on iis.
How can i do it if SomeWebPage.asp will be in other web folder. On same IIS server, but it will be specific web?
I use IIS 5.1 for developing and finished program will run on IIS 6.0.
Problem was that it was different applications.
SessionTransfer.asp must be it same application like SomeWebPage.asp (it wasn't)
and
SessionTransfer.aspx must be it same application (pool) like SomeWebPage.aspx (it was)
It ws teddy-bear problem. When we start discus about this, i realized where is problem :-D
thanks amit_g

select login page for forms authentication based on custom rules

i have a web site that uses forms authentication. the problem is that i have the site installed multiple times on the same production servers because i need to have a few different login pages (based on the domain in this case). after the domain specific login page, the rest of the site is the same. obviously, this requires a lot of maintenance as each new version has to be installed multiple times on the server (with varying the login page in the web.config file).
so i thought is there a way to install the site on 1 folder on the disk, have a web site on the IIS take in all the needed domains and make some http module (or some other solution) in which i could give it a list of domains and the forms authentication for that domain. this way make the login page used by each site change according to the domain while still having only one site to maintain on the server.
Thanks
Dani Avni
I have seen this go a number of ways and a lot of it depends on how you have things setup in IIS.
If all domains are on the same IIS website the most common solution would be to create a httpmodule, or even an actual .aspx page, that loads configuration and based on the requested URL send the user to the right login page. You could even do a "Server.Transfer()" if you want the users URL to stay the same. Then in the web.config you still set a single login page. Just make sure that each other login page allows anonymous users access.
If all domains are separate IIS sites, i would recommend at that point just maintaining different copies of the sites. But the real question is why you need different logins.
My workplace has a couple of web applications that do exactly what you are trying to describe. There are a couple of approaches we have used, depending on the situation.
The more common approach we use is to have all the actual sites on IIS point to the same directory. The logic for the login gets the URL, determines which client site is being requested, and takes that into account on login. The actual login page is the same for all client sites, though, so it's just determining which database to use.
If you want to do anything fancier than that, another approach we have used is to create our own MembershipProvider, at which point you can basically do whatever you want. You should have access to HttpContext.Current if your class is being called by the ASP.NET authentication provider (you would set the membership provider in Web.config to your provider).

Re-publishing an ASP.NET Web Application While Site is Live

I am trying to get a grasp on how to handle updates to a live, functioning ASP.NET (2.0 or greater) Application while there are users on the site.
For example, suppose SO is an ASP.NET Web Application project. The project code compiles down to the single .DLL in the BIN folder. Now, there are constantly users on SO, so what would happen to users' actions/sessions if you would use the Visual Studio .NET "Publish" feature (or just FTP everything again manually) while they are using the site?
Would creating an ASP.NET Web Site, instead, alleviate any problems that may or may not exist with the scenario above? I am beginning to develop a web site as a user-driven Web Application, and I want to make sure that my inexperience with this would not potentially annoy the [potentially] many users that I [want to] have 24/7.
EDIT: Sorry, I should have put this in a more exact context. Assume that this site is being hosted by a web hosting service with monthly fees. I won't be managing the server itself, just what the web host allows as a user of their services.
I create two Web sites in IIS. One is the production Web site, and the other is a static Web site with an HttpHandler that sends all requests to a single static "We're updating" HTML page served with an HTTP 503 Service Unavailable. Typically the update Web site is turned off. When it's time to update, we stop the production Web site, start the update Web site, and now we can fiddle with the production Web site all we want without worrying about DLLs being locked or worker processes needing to be spun down.
I started doing this because
App_Offline.htm really does not work well in Web Gardens, which we use.
App_Offline.htm serves its page as 404, which is bad if you're down for a meaningful period of time.
We can start the upgraded production Web site with modified settings (only listening on localhost), where we can do a last-minute acceptance/verification that everything is working before we flip the switch, turning off the update Web site and re-enabling the production Web site.
Things this does not solve include
Any maintenance that requires a restart of the server--you still have downtime where no page is served.
Any maintenance that diddles with the .NET runtime, like upgrading to the latest service pack.
Other approaches I've seen include
Having two servers. Send all load balancing requests to one server, upgrade the other one; then rinse and repeat. Most of us don't have this luxury.
Creating multiple bin directories, like bin-1.0.0.0 and bin-1.1.0.0 and telling ASP.NET which bin directory to use in the web.config file. (One advantage of this is that reverting to a previous binary is just editing a config file. A disadvantage is that it's harder to revert resources that don't end up in your binaries, like templates and images and such.) I don't remember how this actually worked--I think the application did some late assembly loading in its Global.asax based on its own web.config section (since you touched the web.config, the app had restarted, so it was okay).
If you find a better way, let me know!
Changing to the asp.net web site model won't have any effect, as the recycle will also happen, some of changes that trigger it for sure: web.config, global.asax, app_code.
After the recycle, user will still be logged in because asp.net will just validate the syntax. That is given you use a fixed machine key, otherwise it will change on each recycle. This is something you want to do anyway as other stuff can break if the key change across requests i.e. viewstate validation, embedded resources (decryption of the url fails).
If you can put the session out of process, like in sql server, you will avoid loosing the session. If you can't, your code will have to consider that. There are plenty of scenarios where you can avoid using session, and others were you can wrap it and re-retrieve the info if the session was cleaned. This should leave you with a handful specific cases that you know can give trouble to the users, so for those you do some of the suggestions others have already made.
One solution could be to deploy your application into a load balanced environment (web farm).
When deploying a new version you would use the load balancer to redirect requests to the server you are not deploying to.
App_offline.htm is great solution for this I think.
in SO we see application currently unavailable page when a deployment begins.
I am not sure how SO handles it.. But we usually put a holding page. So what ever the user has done (adding question or answering questions) does not get updated. As soon as he updates something he will see a holding page asking him to try after sometime.
And if I am the user I usually press the back button to make sure what I entered is saved in the browser history so that I can post later.
Some site use use are in clustered environment so I take one server offline and inform the load balancer that she will not be available and once I make sure that the new version is working fine I make it live.. I do the same thing for the next server.
Do we have any other option?
It is not a technical solution, but set up a scheduled maintenance window. You can annoucement in advance giving your user base fair warning that there is a possiblity that the application will not be available during that time frame.

Resources