ASP.NET Application Not being accessed by web.config Writing permissions - c#

2 Situations here of permissions and access:
Cannot Read Configuration File due to Insufficient permissions
This has happening on every single VM instance of Windows Server V. 2019 standard Build 17763.rs5
Solution One by many obfuscated answers in this website: change the Application Pool settings in Advance settings, Identity to LocalSystem: Server responds to provide the basic pages, But no layouts, css, no images, Nothing, Pure HTML served at the end and Modules not even signalled (thank you VS Debugger for telling me this 10 times in a row)
Solution deux Use Windows Security ownership and add the role of the IIS and the other variants that server other roles, NOPE, nothing. also probably security risk.
Situation 2
My Workstation had replicated same deployment process from ASP.NET MVC template from visual studio 2019 and application ran fine. Once.
I had a deployed WebApp in my local machine workstation with the Default template for ASP.NET in Framework (not core, I see you there dude), and the IIS module built, worked fine, did it is purpose. and Only worked in my workstation and my final goal is to be it deployable on other machines... UNTIL:
Cannot add modules to Website Templates made in ASP.NET (Framework)
After that IIS does not allow me to do anything,some Roslyn something in some answers but that didn't work, but were mostly manual removal of it to make it work, which doesn't fit to make a deployment to many computers at once in few clicks (not my choice).
Did my VS updated something? or IIS? Why my regular setup worked just few days ago and now Nothing, even from scratch cant do it's purpose,
Any Ideas? Questions to my questions?

Related

MVC Shows Directory Listing Not Loading Application

I have a project that for some reason isn't loading the project, but just is showing me the directory listings. I have even tried running it in local IIS to see if it makes a difference and it doesn't
Things I have tried
modules runAllManagedModulesForAllRequests="true"
remove and reinstall IIS from manage windows applications in control panel
If I create a template MVC project in visual studio and run it , it runs fine so that makes me think its not my configruation. Other uses with the same project and web config are having no problem getting the site to load.
Also if I try and goto /Home/Index I get a 404 error. Not sure if that helps in any way
Any other ideas I may be missing here
IIS 10 on Windows 10
Check that IIS is installed and features you require are enabled
Register Asp.Net in Windows 10 for the Framework version you use.
dism /online /enable-feature /all /featurename:IIS-ASPNET45
Remove read-only tick and grant IIS with permissions on the folder your application is deployed.
You need to go over your IIS configurations again, do re-check whether you have the “Default Document” set for your website in IIS Manager.
Also, if you’re running directly via Visual Studio, check whether you have selected the relevant “Project” as the “Startup Project” for the Solution (visit https://msdn.microsoft.com/en-us/library/a1awth7y.aspx).
If the above fail, do recheck the IIS Permission for the particular project (visit https://support.microsoft.com/en-us/help/313075/how-to-configure-web-server-permissions-for-web-content-in-iis)
Lastly as mentioned above, do un-check the "Read Only" Flag if its there.
Do share your feedback and let me know if your problem still persists.

Is it possible to persist session data on IIS Express cross different web projects in Visual Studio

We have an existing ASP.NET Web Forms application which contains many different Visual Studio web projects. All web projects were configured to run under same localhost root path (e.g. http://localhost:12345/main/projectspecificname). We use state server to keep the session data and cookieless is set to false.
This approach worked OK when using VS2012 and ASP.NET Development Server. However when we tried to run same application from VS2015 + IIS Express we found it cannot keep session data when redirects happen between different web projects. For example, when calls Response.Redirect("project2/index.aspx") from project1/login.aspx, from Page_Load event in project2/index.aspx I see the session variable lost all the data carried on it(i.e. Session.Count == 0). Same debug procedure against ASP.NET Development Server returns a count greater than 0. Again, for IIS Express, all different projects were configured to use project URL like http://localhost:12345/main/projectspecificname.
I have searched a bit and found this SO post IIS Express doesn't keep session data which mentioned a solution as to disable Browser Link in VS, but that doesn't work for my case. I am just wondering whether we missed some settings or this approach won't work for IIS Express. Any help is appreciated.
I found a solution to this problem. Looks like IIS Express treated these projects as different web applications so session initialized every time it tried to connect to another project.
By default Visual Studio creates an <application> node holding information like virtual path, application pool and physical path under <site> section in applicationhost.config for each web project. Remove <application> nodes for the web projects you don't want to run as a separate web application will make them run under same web site as per their physical path indicate.Therefore, session data can be correctly maintained between pages from different projects as they are considered in the same application now.

published website w/ Crystal Reports not running on server IIS 7.5

I have 2 visual studio 2010 projects that use Crystal reports ver 13.02 differently.
1 works and the other is getting an object reference not set to an instance of an object error.
The first app, I developed from the ground up as a web application, that uses several existing crystal reports and are working using the crystal reports viewer. Its is a web application project using asp.net 4.0 framework in c#.
The other project was an older VB website project that I upgraded from .net 2.0 to 4.0 and was working fine until I had to upgrade it to 13.02. This project does not use the viewer but only prints the data to the report. On my development laptop under visual studio it runs and prints fine, but not when published to both my laptop's IIS 7.5 and the server's IIS 7.5.
I get this error and have exhausted every possible option. It can't be the driver as the web applications project works fine on both my machine and the server. I'm suspicious that I will be forced to convert the project to a web applications project before an answer is found... but would prefer to find an answer to resolve it as it is.
Update
After further debugging I have discovered that the problem is the PrintToPrinter method that, again, works fine in development mode, but not when published.
Does your web.config file for the VB application have all the necessary Crystal references? I've been learning over the last few days that it's pretty quirky.
Resolved Issue
The printer really was not found, despite being there. This is because IIS does not have the same access to resources as does users, rightfully so, and access needs to be granted through either the registry entry under the default users key or security options for the printer need to be set to an IIS account to be set under the Identity option under IIS, in the application pool that the web application is using.
The complete process is also detailed at this link SAP site where the result was two fold.
I used this code snippet to loop through all available printers (I copied and pasted this from SAP, I used C# for my app and creates a list box to add) and showed them on the web page during the print process:
Dim myPrinter As String
For Each myPrinter In System.Drawing.Printing.PrinterSettings.InstalledPrinters
add to list
Next
Under the web server, through Computer Management I added the Local Service IIS id to the Print Operators group.
Under IIS, using the "Advanced Settings" of the Application Pool the web site is using, I changed the Identity field to LocalService
I verified the printer was now available by running the code snippet again and it was, then printed the report and it ran and printed fine.
It took a while to find this answer, and I could not have gotten there without the assistance provided which directed me to the answer. I hope this helps out someone else.
You need to download and install CR on you production server. *.msi
For example: CRRuntime_64bit_13_0.msi

Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list

To be honest, I've tried to turn a dirty trick on IIS and just when I thought that I was going to get away with it, I realized my workaround doesn't work. Here's what I've tried to do:
1) I have ASP.NET application which has Preloader class that inherits IProcessHostPreloadClient and does all the heavy initialization in Preload method implementation (application is complex and it's a part of an enormous system, so it requires approximately 2 minutes to establish connections to all necessary services and pre-instantiate some Unity registrations).
2) I have a lot of work that needs to be done on application shutdown (unsubscribing, disconnecting, disposing,...), and I guess the best place to do it is in *Application_End* method located in Global.asax.
3) Everything works just fine when I have user activity (first request after the Application Pool that contains aforementioned web application is started will cause *Application_Start* to be called and afterwards *Application_End* is called on Application Pool stop or recycle), but problems occur when there is no user activity and application tries to restart itself after being active for 48 hours (configured requirement). Since there was no requests, application officially didn't get started. Ergo, it can't be gracefully stopped since *Application_End* won't be called.
4) Now comes the messy part... I've tried to make a GET request from code at the end of the Preload method, and it worked. But this solution seemed bad to me, even though it worked. So, I've tried a lot of things, and the last thing I tried was this:
SimpleWorkerRequest swr = new SimpleWorkerRequest(string.Empty, string.Empty, tw);
HttpRuntime.ProcessRequest(swr);
... and that has done it's purpose. *Application_Start* was called, (I've checked response, it was containing login page that was supposed to be displayed in initial request) and on Application Pool shutdown application ended gracefully by doing necessary work in *Application_End*.
BUT
After the application was started (preloaded and initiated) in this manner, this is what happened when I wanted to reach application via Web browser:
HTTP Error 500.21 - Internal Server Error
Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list
I am unable to figure this out. Can anybody tell me why this happens and how to fix it?
If I don't figure this out, I will go back to first solution (sending GET request from code) but this problem will bug me since I don't even have an idea what's wrong.
Try to re-register ASP.NET with aspnet_regiis -i. It worked for me.
A likely path for .NET 4 (from elevated command prompt):
c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
http://forums.iis.net/p/1190643/2026401.aspx
If you're running into this error with Windows 8/Windows Server 2012 and .Net 4.5 follow these instructions here:
http://www.britishdeveloper.co.uk/2013/01/handler-extensionlessurlhandler.html
Go to "turn Windows features on or off"
Then Internet Information Services
Then World Wide Web Services
Then Application Development Features
And then enable ASP.NET 4.5
This worked for me (although the wizard and wording is a little different in Windows Server 2012, but you'll figure it out). With this being said, why this is necessary after installing everything through the Web Platform Installer including all of the dependencies is completely beyond me...
Despite following most of the advice on this page, I was still getting problems on Windows Server 2012. Installing .NET Extensibility 4.5 solved it for me:
Add Roles and Features > Server Roles > Web Server (IIS) > Web Server > Application Development > .NET Extensibility 4.5
For Windows 10 / Windows Server 2016 use the following command:
dism /online /enable-feature /featurename:IIS-ASPNET45 /all
The suggested answers with aspnet_regiis doesn't work on Windows 10 (Creators Update and later) or Windows Server 2016:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
Microsoft (R) ASP.NET RegIIS version 4.0.30319.0
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation. All rights reserved.
Start installing ASP.NET (4.0.30319.0).
This option is not supported on this version of the operating system. Administrators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Windows Features On/Off" dialog, the Server Manager management tool, or the dism.exe command line tool. For more details please see http://go.microsoft.com/fwlink/?LinkID=216771.
Finished installing ASP.NET (4.0.30319.0).
Interestingly, the "Turn Windows Features On/Off" dialog didn't allow me to untick .NET nor ASP.NET 4.6, and only the above DISM command worked. Not sure whether the featurename is correct, but it worked for me.
Run one of these commands :
For 32 Bit Windows OS:
c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
For 64 Bit Windows OS:
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -I
This https://stackoverflow.com/a/13266763/1277458 works perfectly. But if you have 64-bit operation system use Framework64 instead of Framework in path:
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
The problem
You are using SimpleWorkerRequest in a scenario that it wasn't designed for. You are using it inside of IIS. If you look at the prior MSDN link (emphasis is mine):
Provides a simple implementation of the HttpWorkerRequest abstract class that can be used to host ASP.NET applications outside an Internet Information Services (IIS) application. You can employ SimpleWorkerRequest directly or extend it.
Also, if you look at the MSDN documentation for the System.Web.Hosting namespace (SimpleWorkerRequest is in this namespace), you will also see something similar to the above (again, emphasis is mine):
The System.Web.Hosting namespace provides the functionality for hosting ASP.NET applications from managed applications outside Microsoft Internet Information Services (IIS).
The solution
I would recommend removing the call to SimpleWorkerRequest. Instead, you can use a Microsoft solution to make sure your web site automatically starts up after it recycles. What you need is the Microsoft Application Initialization Module for IIS 7.5. It is not complicated to configure, but you need to understand the exact options. This is why I would also recommend the Application Initialization UI for IIS 7.5. The UI is written by an MSDN blogger.
So what exactly does the Microsoft solution do? It does what you are trying to do - IIS sends a "get" request to your website after the application pool is started.
In my case (Windows 10 + IIS 10) i had to open "Turn Windows Features On or Off" and then go to Internet Information Services > World Wide Web Services > Application Development Features > and check ASP.NET 4.6
I solved this problem, adding in "Turn Windows features on or off"
The option ASP.NET 4.7
Making this its own post because this had me going for hours.
I saw maybe a dozen of similar posts here and elsewhere about this problema and the aspnet_regiis fix. They weren't working for me, and aspnet_regiis was acting odd, just listing options etc.
As user ryan-anderson above indicated, you cannot enter .exe
For those less comfy with things outside IIS on the server, here's what you do in simple steps.
Find aspnet_regiis in a folder similar to this path. c:\Windows\Microsoft.NET\Framework\v4.0.30319\
Right-click command prompt in the start menu or wherever and tell it to run as administrator. Using the windows "Run" feature just won't work, or didn't for me.
Go back to the aspnet_regiis executable. Click-drag it right into the command prompt or copy-paste the address into the command prompt.
Remove, if it's there, the .exe at the end. This is key. Add the -i (space minus eye) at the end. Enter.
If you did this correctly, you will see that it starts to install asp.net, and then tells you it succeeded.
Make sure that you have set your application-site version from v2.0 to v4.0 in IIS Manager:
Application Pools > Your Application > Advanced Settings > .NET Framework Version
After that, install your ASP.NET.
For 32-Bit OS (Windows):
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
For 64-Bit OS (Windows):
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
Restart your application-site in IIS Manager and enjoy.
I know this is an oldie, but thought I might add some value. For those of us running Server Core outside of a domain (domain members can just run Server Manager remotely to add/remove features/roles), you have to resort to command lines.
Powershell users can type "Install-WindowsFeature Web-Asp-Net45"
That should be equivalent to using server manager.
I was challenged by the same error message, with .net 4.7 installed.
The solution was to follow one earlier mentioned post to go with the "Turn Windows feature on or off", where the ".NET Framework 4.7 Advanced Services" --> "ASP.NET 4.7" already was checked.
Further down the list, there is the "Internet Information Services" and subnote "Application Development Features" --> "ASP.NET 4.7", that also needs to be checked.
When enabling this, allot of other features are enabled... I simply pressed the Ok button, and the issue was resolved.
Screendump of the windows features dialog
Installing .NET 4.7 worked for me. I only had 3.5 installed prior.
I'm working on Windows Server 2012. .NET Extensibility 4.5 feature is on. WebDAVModule removed.
I was still getting 500.21 error on ASP.NET route '/docs'.
Changing 'skipManagedModules' to false fixed the problem.
<applicationInitialization doAppInitAfterRestart="true" skipManagedModules="false">
<add initializationPage="/docs" />
</applicationInitialization>
Thanks to https://groups.google.com/forum/#!topic/bonobo-git-server/GbdMXdDO4tI
I had this problem and found that removing the following folder helped, even with the non-Express edition.Express:
C:\Users\<user>\Documents\IISExpress
This error started happening to me out of nowhere last week, affecting the existing web sites on my machine. I had no luck with it trying any of the suggestions here. Eventually I removed WebDAV from IIS completely (Windows Features -> Internet Information Services -> World Wide Web Services -> Common HTTP Features -> WebDAV Publishing). I did an IIS reset after this for good measure, and my error was finally resolved.
I can only guess that a Windows update started the issue, but I can't be sure.
You could fix it by change the "ExtensionlessUrlHandler-Integrated-4.0" type in iis to System.Web.DefaultHttpHandler
For me, removing WebDAV from my server caused the application to return a 503 Service Unavailable Error message when using PUT or DELETE, so I re-installed it back again. I also tried completely removing .NET Framework 4.5 and reinstalling it and also tried re-registering as suggested but to no avail.
I was able to fix this by disabling WebDAV for the individual application pool, this stopped the 'bad module' error when using PUT or DELETE.
Disable WebDAV for Individual App Pool:
Click the affected application pool
Find WebDAV Authoring Tools in the list
Click to open it
Click Disable WebDAV in the top right.
Ta daaaa!
I still left the remove items in my web.config file.
<system.webServer>
<modules>
<remove name="WebDAVModule"/>
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
<system.webServer>
This link is where I found the instructions but it's not very clear.
This maybe not a usefull solution for OP but it concerns the same "error" message.
We are hosting PHP pages on IIS8.5 with .NET 4.5 installed correctly.
We make use of the preload functionality to make sure our application is always responsive across the board.
After a while we started getting this error at random.
In the web.config : I put skipManagedModules to true, -> don't do this!
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<applicationInitialization skipManagedModules="false" doAppInitAfterRestart="true">
<add initializationPage="/" />
</applicationInitialization>
...
Although website is php, the routing to the paging is managed by the modules!!!
I also ran into that problem. My MVC4 App is running on a Windows Server 2012 R2 with IIS 8.5. None of these posted solutions worked for me...installing the missing frameworks through IIS Features could have solved it but the installation always failed.
I had to use the Web Platform Installer and installed the following packages:
I was facing this issue in a web application hosted on a shared hosting server. So obviously did not have direct access to IIS, so could not apply many solution proposed here.
On the hosting provider's control panel I enabled error logging for IIS and ASP.Net. And then got to know that error actually lied in a missing cshtml.

Visual Studio 2008 Development Server not starting

I have a C# web service that I am trying to debug in Visual Studio 2008, and when I try to run it, Internet Explorer pops-up as expected, but it just displays 'waiting for response from localhost...' in the status bar. I have left it running for a few minutes and it never responds.
I have other web services that I am able to debug fine, is VS2005 and 2008. The problem web service is impersonating a different identity in the web.config file, but I have no problems with this same user on a different web service (in VS2005).
Does anybody have any ideas on what might be preventing it from starting up? Interestingly, a colleague has the same problem with a web service that IS working on my machine, even though we are working with identical code. Something must be configured differently...
By the way, I've noticed that the 'Temporary ASP.NET Files' folder is missing from both
C:\Windows\Microsoft.NET\Framework and C:\Windows\Microsoft.NET\Framework64... I certainly haven't deleted them, and other web services debug okay, so is this just a red herring?
We are also on a domain which has its own firewall (outside of the developers' control) - could this be blocking it?
EDIT: I have just removed the user impersonation for a quick test, and it worked. So there must be something about Visual Studio 2008 that does not want to run when impersonating THIS particular user. Any ideas what configuration I would need to change to correct this?
I have had the same issues with impersonation; I don't know if Cassini (the built-in VS web server) supports this properly. About the best advice I can give is to either use Local IIS with an app pool running as your impersonated user or to attach your debugger using remote debugging to a remote IIS server.
I believe using Local IIS will attach correctly & automatically if configured as much in the Web tab of Project Properties. You'll have to run VS as an admin to get the virtual directories setup automatically by VS in IIS.

Categories

Resources