Visual Studio Web Deployment project breaks ASPNET account permissions - asp.net

I have built an ASP.NET web application with Visual Studio 2008 and target framework version 2.0. I have created a Web Setup project to deploy this at multiple target OSes.
For the setup project, I have written a custom action which gets executed on "OnCommitting" event. This custom action adds wildcard script mapping for routing all requests through ASP.NET engine.
FileMon suggests that an error occurs while creating a file in the following directory:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
The user account which was attempting this action was IWAM_<host name>.
The problem is after running this setup, if I try to access any url on the newly installed site, I received the error message:
Server Error in '/myapp' Application.
Failed to access IIS metabase.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.Hosting.HostingEnvironmentException: Failed to access IIS metabase.
The process account used to run ASP.NET must have read access to the IIS metabase (e.g. IIS://servername/W3SVC). For information on modifying metabase permissions, please see http://support.microsoft.com/?kbid=267904.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
I have already tried these options after 2 days of googling:
Run aspnet_regiis -i
Run aspnet_regiis -ga \ASPNET
Run aspnet_regiis -u and then aspnet_regiis -i
Option 3 has worked for me as of now, but, I want avoid using this, since, my web app will be deployed on a machine which might already be hosting some other app on IIS and I do not want to disturb these apps.
Can anyone suggest me a workaround for this?
B.T.W. my current system has .Net framework 3.5 and VS2008 installed on Win XP SP3 and IIS 5.1.
Thanks,
Vamyip

Your best bet is a custom bit of script in the installer package that checks permissions and then runs the command based on that information.
On a server OS this shouldn't be necessary since the default user for the application group will be in the IIS_WPG and have permissions to the temp directories. Windows XP has a bugged up version of IIS that is non-standard and doesn't follow all the rules. If your expected deployment environment is Windows Server 2003 or better then your installer should work as-is.

Related

IIS: Parser Error Message: Could not create type

I am trying to build a simple web service in C# using VS2015 to be hosted on Windows Server 2012R2.
I have the code written and it works properly when hosted in the Visual Studio debugger. The debugger will launch IE and give me the UI to test the simple methods in my code. I can enter a temperature in Celsius and get back the temperature in Farentheit. So my understanding is that my code itself is working.
However, when I publish my project and attempt to load it in IE, I get:
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not create type 'TestAutomation.AutomationInterface'.
Source Error:
Line 1: <%# WebService Language="C#" CodeBehind="~/App_Code/WebService.cs" Class="TestAutomation.AutomationInterface" %>
Source File: /TestToolsAutomation/AutomationInterface.asmx Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.81.0
I am publishing my project by going to Build -> Publish Web App. I am selecting "File System" as my publish method and am publishing to "C:\inetpub\wwwroot\MyAppName" in the Debug configuration with no check boxes in the File Publish Options. When I publish, I have the following files in the MyAppName folder:
-AutomationInterface.asmx
-Web.config
\App_Code
WebService.cs
The obvious issue I see here is that there is no .dll file created with my compiled code. I'm far from an IIS expert, but isn't this supposed to be created the first time a user requests the page?
I then re-published and checked "Precompile during publishing" in the file options. When I do this, a \bin folder is created with files "App_Code.compiled" and "App_Code.dll" files. However, I get the same error in the browser.
Because my code works in the VS debugger but not when hosted in IIS, I suspect the problem is on the IIS side of things, but I'm not 100% certain of that.
When I request the IIS page in IE, I get an event 1310 with source "ASP.NET 4.0.3.30319.0" in the application event log that says "Event code: 3006
Event message: A parser error has occurred" along with a stack trace that shows a bunch of System.Web.Compilation functions.
I have searched for this error on Stack Overflow and other sites, but none of the suggested solutions appear to solve my particular problem.
I would appreciate any help the community could offer.
UPDATE: I enabled failed request tracing on the server. It appears that the error happens here:
154. view trace
Warning
-MODULE_SET_RESPONSE_ERROR_STATUS
ModuleName
ManagedPipelineHandler
Notification
MAP_REQUEST_HANDLER
HttpStatus
500
HttpReason
Internal Server Error
HttpSubStatus
0
ErrorCode
The operation completed successfully.
(0x0)
ConfigExceptionInfo
ManagedPipelineHandler
I lack the background to fully understand what IIS is trying to tell me. Any tips would be appreciated.
After struggling with this for hours and making all kinds of settings changes, and uninstalling and reinstalling IIS several times, I finally solved this.
I had to right-click on the folder in which I published my files in IIS Manager and select "Convert to Application." It's now working!
Here are a few possible ideas to explore:
Have you looked at the permissions for the account that the Application Pool in IIS is using to run this? There can be ASP.Net Temporary files that aren't being generated that could be an issue here.
Is ASP.Net registered with IIS? I've remembered more than a few times to have to run "aspnet_regiis -i" on servers to install the ASP.Net part so that it'll be present within IIS.
Is IIS configured to allow ASP.Net requests? In the IIS Manager on the machine level there is an "ISAPI and CGI Restrictions" to note.
Update: Perhaps you could look at the configuration for the Application Pool and see which .Net version it is using and whether it is integrated or classic mode. Those would be the next level of things to examine.

Remote Web Deploy not working

I have developed several ASP.NET 4.5 applications and I want to publish them to a remote computer running IIS 8, using Web Deploy.
I created two sites in IIS8, Site1 and Site2. I created a single IIS User and I gave permission to access both sites to this user.
I can publish the first site via Web Deploy, but I cannot publish the second site.
When I try to publish the second site, I get this error in Visual Studio
2>Start Web Deploy Publish the Application/package to https://27.147.144.98:8172/msdeploy.axd?site=NSU ...
2>Adding ACL's for path (NSU)
2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(4255,5): Error : Web deployment task failed. ((6/30/2015 12:36:37 PM) An error occurred when the request was processed on the remote computer.)
2>
2>(6/30/2015 12:36:37 PM) An error occurred when the request was processed on the remote computer.
2>The server experienced an issue processing the request. Contact the server administrator for more information.
2>Publish failed to deploy.
The first site is published correctly always. The problems occurs only for the second site.
I had this error but also had Fiddler2 running which seemed like it was interfering with the deployment. When I closed it, things worked again. Make sure you test the connection beforehand.

Upgrading to 2K8 Server, An error occurred loading a configuration file: Failed to start monitoring changes to '\\networkshare'

I moved my site off of a 2k3 server over to a 2k8 server. The site has a virtual directory pointed to a network share which has different credentials than the one used by the site. I set the virtual directory to use the correct credentials and it can browse the share fine through explorer, but when I try to load files (images, etc) through a browser I get the following asp.net error:
Server Error in '/' Application.
Configuration Error Description: An error occurred during the
processing of a configuration file required to service this request.
Please review the specific error details below and modify your
configuration file appropriately.
Parser Error Message: An error occurred loading a configuration file:
Failed to start monitoring changes to '\\networkshare'.
Source Error:
[No relevant source lines]
Source File: \\networkshare\web.config Line: 0
Version Information: Microsoft .NET Framework Version:2.0.50727.5456;
ASP.NET Version:2.0.50727.5456
The network share does not have a web.config.
I tried the solution provided here, but that did not solve the issue and this site isn't using impersonation. Do I need to enable impersonation? This was working correctly on win2k3.
OK, so based on our comments it sounds like this is either a share permissions problem or an NTFS permissions problem (same resolution, different dialog).
In IIS6 you typically had the worker process running as NETWORK SERVICE and that's what you would give permissions to to access shares and files on the network.
In IIS7.5 the application pools now run under an AppPool identity, one specific to the application pool that the website is running under. This link should be helpful: http://learn.iis.net/page.aspx/624/application-pool-identities/
As a quick fix (although I recommend reading up on it) though, you can go into the application pool, go to advanced properties, and set the identity back to NETWORK SERVICE.

MSBuild Extension Pack IIS7 task on remote server error

I have set up a Continuous Integration build with TeamCity and MSBuild. I am using the MSBuild Extension Pack, primarily for its IIS7AppPool Task. My goal is to stop an IIS app pool before the build script does a deployment step and start the app pool afterwards. The IIS app pool is on a different server from the build agent.
I have used the following MS Build code to stop IIS:
<MSBuild.ExtensionPack.Web.Iis7AppPool TaskAction="Stop" MachineName="$(DeploymentServerName)" Name="$(WebAppPoolName)" Username="$(DeploymentServerUsername)" UserPassword="$(DeploymentServerUserPassword)" />
I have set up a local admin user account on the web server, and used its username and password above as $(DeploymentServerUsername) and $(DeploymentServerPassword).
The error I am receiving is:
[MSBuild.ExtensionPack.Web.Iis7AppPool]
E:\TeamCity\BuildAgent\work\1a1dc058c29f0f12\BuildAndDeployment\Build_DevCI.proj(153,
5): UnauthorizedAccessException: Retrieving the COM class factory for
remote component with CLSID {2B72133B-3F5B-4602-8952-803546CE3344}
from machine DEPLOYMENTSERVERMACHINENAME failed due to the following
error: 80070005 DEPLOYMENTSERVERMACHINENAME.
I have asked our network guys to take down any firewalls between the two machines, but I still get the same error.
Can anyone see anything wrong with my syntax or offer any advice on how to get this to work?
I can get the task to stop an IIS app pool on my local machine ok, so my syntax should be right.
I have looked at this post, but I don't think it's the same problem:
MSBuild remoting to server throws COMException error

ASP.NET Application Goes to 500.21 ... until IIS Reset + Clear Tempoary ASP.NET Cache

We're seeing an odd pattern in our QA Lab. We have two ASP.NET applications, each deployed on the same Windows 2008 SP2+ box. We have our App Pool running in a Domain Account, and set to never re-cycle. The same 1 App Pool is used by both applications.
After several hours of running fine, new users surfing to a page in our application get the IIS7 Error Page, with a 500.21 error.
If we do nothing but:
1) IISRESET
2) Change folder to c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files and "rd" the 2 applications.
And then surf to our web applications, all is fine.
Then several hours later, however, the 500.21 errors return.
What strikes me as odd is the seeming relationship between clearing the "Temporary ASP.NET Files" folders and the problem going away. I've a practice of clearing the "Temporary ASP.NET Files" folders when installing a new version of our application(s), but not otherwise.
Does this relationship ring familiar to anyone? Is there some new-ish IIS7 feature at work here?
Text of Error:
Server Error in Application "DEFAULT WEB SITE/PAIS"
Internet Information Services 7.0
Error Summary
HTTP Error 500.21 - Internal Server Error
Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list
Detailed Error Information
Module IIS Web Core
Notification ExecuteRequestHandler
Handler PageHandlerFactory-Integrated
Error Code 0x8007000d
Requested URL http://localhost:80/PAIS/Admin.aspx
Physical Path C:\0_Georgia\GA_IS_100142\PortfolioArchiveImageServer\Admin.aspx
Logon Method Anonymous
Logon User Anonymous
Most likely causes:
• ASP.NET is not installed or incompletely installed.
• A configuration typographical error occured.
• Unfavourable pre-condition evaluation exists.
Things you can try:
• If ManagedPipelineHandler is missing, ensure that:
o ManagedEngine is in .
o ManagedPipelineHandler is in , with correct pre-conditions.
• Install ASP.NET.
• Ensure all system.webServer/handlers#modules are in system.webServer/modules#name.
• Review pre-conditions in the and sections.
Links and More Information IIS core does not recognize the module.
View more information »
Thanks in advance,
Howard Hoffman
Faced the same problem and the fix was easy.
1) Open visual studio 2010 command prompt.
2) Run the command aspnet_regiis.exe -i
We found the actual problem, with MS ASP.NET support's help. It's pretty subtle. I think MS has said they will fix the issue in a follow on to the App Fabric release (which is now RTM). Fingers crossed.
The problem consistently occurs in this scenario:
1) ASP.NET web application not yet running. It includes WCF Net.Pipe and / or Net.Tcp bindings. I think the same would occur for NetMsmq but did not try it.
2) An inbound NetPipe or NetTcp WCF Windows Activation Service request is the initial request that starts the App Domain.
3) Application uses an 'Integrated' IIS App Pool (IIS7 or IIS 7.5)
4) The application uses HttpServerUtility.Execute during that 1st request.
It turns out that our application was firing an ASP.NET Health Monitoring event during the very 1st WCF operation -- the very operation that caused Windows Activation Service (WAS) to start our application. Our Health Monitoring configuration includes the TemplatedMailWebEventProvider.
Our application is using an 'Integrated' IIS App Pool.
The TemplatedMailWebEventProvider is implemented to create an email message body as HTML. It uses the System.Web.HttpServerUtility.Execute(string, TextWriter, Boolean) overload.
For this use case that overload does the wrong thing -- it initializes a 'Classic' IIS App Pool based HTTP pipeline. Because that's the wrong pipeline for an 'Integrated' IIS App Pool the pipeline gets corrupted with the next HTTP request -- which is actually the first inbound HTTP request.
So you get the 500.21 error for all future HTTP requests until the application is re-cycled. You don't need to perform the relatively drastic steps of IISRESET, clearing Temporary ASP.NET cache to clear up the error -- just restart the app via saving web.config and avoid the particular startup path that causes the error.
MS suggested a workaround for us -- use the SimpleMailWebEventProvider instead of the TemplatedMailWebEventProvider. That does work, since it takes HttpServerUtility.Execute out of the code path for the first request.
I'd suggested that MS introduce a new web.config <system.web> boolean setting -- UseIntegrated -- that let's the application specify the typeof App Pool to initialize with. Evidently IIS does not forward the App Pool type to ASP.NET, so my sugggestion is a work-around to that.
The TemplatedMailWebEvent provider is much more user friendly than the SimpleMailWebEventProvider, and we do hope MS addresses the issue.
Thanks all for reading,
Howard Hoffman
1. IIS 7 throws an exception as shown in below
2. Open visual studio 2010 command prompt in Administrator mode and execute aspnet_regiis.exe -i
3. Problem fixed, as shown below ASP.Net Application and ASP.Net MCV Application are running smoothly.
The problem more likely is in the application code. The Temporary ASP.NET Files folder contains pre-compiled copies of your app and will be refreshed every time the applications files are accessed. You can pre-compile these files with aspnet_compiler.exe in the \Windows\Microsoft.NET\Framework\v2.0.50727\ folder. Use the -errorstack option allow for more information to be generated about the error you are getting. Long running applications that don't recycle will run into problems if they use a lot of memory or retain large amounts of data in an inproc session state. if your sessions contain large amounts of information, consider using a sqlserver-based session manager.

Resources