IIS 7.5 warm up not working with Classic mode - asp.net-mvc-4

IIS 7.5 warm up (IProcessHostPreloadClient) is not working when application pool's Managed Pipeline Mode set to Classic, if the Managed Pipeline Mode set to integrated Mode it works fine.
Not sure if i have to do anything special for classic mode to work
I am following this url
http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx

We had the same problem on our IIS 7.5 (Windows Server 2008 R2). There is a delay about ~30 seconds until the web site appears. We also tried to solve it via ScottGuĀ“s blog with no success. So we installed a cronjob that executes C# code and does a fire-and-forget request to the webserver:
public static void WarmUp(string pUrl)
{
var lWebClient = new WebClient();
lWebClient.DownloadStringAsync(new Uri(pUrl , UriKind.Absolute));
}
Execute the WarmUp:
WarmUp("http://hostname");
After that call + ~30 seconds, our web site will appear directly in the browser.

Related

Kestrel seems to freeze

I have develop an asp.net-core MVC 3.1 application.
This application is hosted on a Linux server.
This webapp is launched by systemd with this command:
/usr/bin/dotnet /pathto/myapp.dll
I have an nginx web server which act as a proxy:
Here is my nginx site configuration:
location / {
proxy_pass http://localhost:5000;
...
}
Here is a description of my problem:
The application is very slow on the first page (about 30-40 seconds. I have a very basic sql server command on this page).
Then the application respond quickly (1 second).
I can go back on the previous page, the application respond quickly
I wait about 2 hours
The first page is slow again.
I am wondering something: Is it possible kestrel deletes at some interval compiled cache or something like that ? And when a user hits again the first page, kestrel compile something on the fly ?
This is strange because my app is stilled compiled (dlls)
Thanks

CryptographicException when deploying IdentityServer4 solution with AddDeveloperSigningCredential to IIS

I have a working Auth service built on IdentityServer3 and .NET Framework. I'm in the process of building a new version of it on IdentityServer4 and ASP.NET Core. In this early stage in development, I'm still using AddDeveloperSigningCredential. When I deploy it to my local development box (Windows 10) in a console window, it runs fine. When I deploy it to IIS Express on my local development box, it gets the following error on startup:
UnauthorizedAccessException: Access to the path 'C:\Program Files\IIS Express\tempkey.rsa' is denied.
I don't really care if it runs in IIS Express (since it runs fine in a console window), but I include this information in case it is relevant to my problem.
When I deploy the solution to a remote server running IIS (Windows Server 2008 R2, IIS 7.5) it fails on startup with this error:
Application startup exception:
Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: Object was not found
at System.Security.Cryptography.CngKeyLite.GenerateNewExportableKey(String algorithm, Int32 keySize)
at System.Security.Cryptography.RSAImplementation.RSACng.GetDuplicatedKeyHandle()
at System.Security.Cryptography.RSAImplementation.RSACng.ExportKeyBlob(Boolean includePrivateParameters)
at System.Security.Cryptography.RSAImplementation.RSACng.ExportParameters(Boolean includePrivateParameters)
at Microsoft.Extensions.DependencyInjection.IdentityServerBuilderExtensionsCrypto.AddDeveloperSigningCredential(IIdentityServerBuilder builder, Boolean persistKey, String filename)
at Orvis.Authorization.Service.Startup.ConfigureServices(IServiceCollection services) in C:\Workspaces\Orvis\orvis-microservices\orvis-authorization\Orvis.Authorization.Service\Startup.cs:line 20
Will IdentityServer4 and, in particular AddDeveloperSigningCredential, work on Windows Server 2008 R2 and IIS 7.5 or do I need a newer development server? Or, if the age of the O/S is not the problem, what else might be causing this error?
Well I got this working. At some point along the way the symptom changed and I'm not sure why, but I'll recount here what I know.
I originally had the .AddDeveloperSigningCertficate call hard-coded in my startup code - like this:
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddInMemoryIdentityResources(Config.GetIdentityResources())
.AddInMemoryApiResources(Config.GetApiResources())
.AddInMemoryClients(Config.GetClients())
.AddTestUsers(Config.GetTestUsers());
That produced the WindowsCryptographicException on startup as noted in the original post. Following some updated IdentityServer4 documentation, I changed that to:
var builder = services.AddIdentityServer()
.AddInMemoryIdentityResources(Config.GetIdentityResources())
.AddInMemoryApiResources(Config.GetApiResources())
.AddInMemoryClients(Config.GetClients())
.AddTestUsers(Config.GetTestUsers());
if (Environment.IsDevelopment())
{
builder.AddDeveloperSigningCredential();
}
else
{
throw new Exception("Need to configure key material");
}
Once I made sure my target server had the correct environment variable to define itself as a Development environment, I think that should have produced the same result. But instead it produced the access denied error that I'd seen earlier in my attempts to deploy locally to IIS Express.
Given that error, I was able to grant the IIS ApplicationPoolIdentity identity write access to c:\windows\system32\inetsrv, which is where it was trying to write the tempkey.rsa developer credential file. This article provides a good overview of ApplicationPoolIdentity and details on how to grant permissions to that identity for your app pool. Granting permissions to that system directory required first taking ownership of the directory.
With all of that done, my service is now running successfully with the developer signing credentials in IIS on my development server.

ASP NET MVC 6 Web App hosted on Azure not running

I have a MVC 6 application which is hosted in Azure as web app. It is running fine on local by iisexpress but when I hosted it in Azure using publish option in Visual Studio, it is not working. It is just waiting to load website. After 4-5 minutes wait, it displays nothing.
I also tested it with static file. I uploaded a static html file in wwwroot folder but it is also not working.
I am not getting how can I see the actual error. Anybody can help me?
Since you've provided almost no information I gonna have to guess, since I had a similar error this weekend when deploying an ASP.NET Core 1.0 WebApp to an Azure App Service.
The issue I was facing was, that the main application wouldn't start. After a couple of hours trying to figure it out I got an error message with the method mentioned in the comments (running web.cmd manually) which returned an Microsoft.AspNet.Server.Kestrel.Networking.UvException: Error -4089 EAFNOSUPPORT address family not supported exception.
I couldn't find anything directly related to it, but was a hint about an IPv6 problem. A few other SO posts hinted that setting http://*:12345 as port binds to both, IPv4 and IPv6. So after I changed the url to http://0.0.0.0:12345 in the hosting.json, it started without issues.
I filled an issue on Kestrel GitHub and this seems to be a bug in Kestrel.
Edit: In response to the comment:
I used to have
{
"server": "Microsoft.AspNet.Server.Kestrel",
"server.urls": "http://*:8081"
}
and changed it to
{
"server": "Microsoft.AspNet.Server.Kestrel",
"server.urls": "http://0.0.0.0:8081"
}
The difference seems to be that http://*:8081 also binds to both IPv4 and IPv6 on the same port, whereas http://0.0.0.0:8081 only binds on IPv4 and not on IPv6.

WCF wsdualhttpbinding strange behaviour at client side that has no clear (Exception details)

to make long story as short as possible, I made a duplex WCF service, using wsdualhttpbinding, tested it on my local machine using Visual Stuido and using IIS7, thigs are working fine (i had to use windows authentication on IIS7 to make it work thu). Any way, I published the duplex service on my company network (LAN network, windows domain, IIS 6) which i used to for many WCF services (basic and ws http bindings and worked fine) and the problem is I can not get the service to work, I tried all possible configurations to the app.config and to the web.config files, still i can not make it work.. The problem is when the client start calling the duplex service It hangs and no error message or whatsoever, and after few minutes it gives me a timeout error.. there is no error at server side ( i have checked the even viewer). There is not error about port 80 or access privileges. Is there anything i am missing? anything i should take care of and i forgot? i have been awake for 20 hours trying to find a solution because i have a time line to follow or my boss will Dispose() Me..
i have tried the following:
1- I set the IsOneWay = true..
2- I run the program as admin.
3- I i set the base address to another port.. same result..
4- I used windows auth, none... same result..
5- i have tried another machine to test the client.. same result.. it hangs with no reponse.
6- I also tried running the client on windows vista, 7 and xp... same result..
7- I have played with all kind of configurations in config files and i made sure its the same on both files (app.config and web.config)..
8- I have added a static constructor in the service side to see if the service was ever reached by the client, i added few lines to add a value in the db.. and nothing was written to db.. so it was never reached..
9- Yes, when i access the service SVC page i see the page and it worked fine.. I could access the metadata as well..
10- restarting the server, restarting IIS server, Recycling AppPool...etc..
I tried all of that and many other solutions and tricks.. same result when the app is on IIS.. the strange thing is, there is no error at server side.. and i only get TimeOut error (if i get it).. While If i tried the service on the IIS installed locally it works fine.. change the config file to point to the company IIS server,,, no luck!
Is there anything i am missing??? could be something simple but i just missed it..

Slow web service (and WCF service) calls from Windows 7

I am building a .NET 3.5 Winforms app that uses WCF services (wsHttp binding) to communicate to my server which gets data from SQL Server and passes it back to the Winforms app (Smart Client). I noticed since running Windows 7 RTM there is about a 30 second delay the first time the WCF communicates, from that point forward it's normal as before.
I noticed another application (Desaware licensing system) that uses ASMX services also experiences this same problem, a startup delay then all is fine.
This first time startup is not a .NET complilation/JIT issue, I can close the app right away and do it again. The server is running Windows 2003/IIS 6. All was fine prior to Windows 7.
I tried removing my anti-virus software, same issue. I cannot figure out why there is this initial delay, a significant one at that. I notice too in the Debug window as the application is starting up a delay as the System.IdentityModel line, it looks as if there is a security/authentication change on Windows 7 I presume that is causing this delay.
Anyone have any suggestions on how to resolve this issue? VS 2008 / .NET 3.5.
Thank you.
I added the following entry into the binding configuration and it appears to have solved the issue.
useDefaultWebProxy="false"
I was experiencing the same problem. I create my proxy using a ChannelFactory object, and found that in addition to specifying useDefaultWebProxy for the binding server-side, it was also necessary to specify the option client-side:
HttpTransportBindingElement httpTransport = new HttpTransportBindingElement
{
MaxBufferPoolSize = int.MaxValue,
MaxBufferSize = int.MaxValue,
MaxReceivedMessageSize = int.MaxValue,
AuthenticationScheme = System.Net.AuthenticationSchemes.Ntlm,
UseDefaultWebProxy = false
}
I found that the issue only occured when using the current Windows credentials. If you pass specific credentials then the performance was as expected. However, setting the UseDefaultWebProxy client side fixed the problem.
Hope this helps someone, somewhere!
A 30 second delay, sounds like it is waiting for something and then timing out after 30 seconds.
It is probably something to do with the authentication between your windows 7 machine and the server. Checking the event log would be a good place to start.
This worked for my Windows 7 and connecting to a WebServer
useDefaultWebProxy="false"
Thank You
Douglas