Cant write to log file in IIS 7.5 - c#

I have a web service in .Net 4.0. I'm deploying said web service to two IIS servers each running IIS 7.5 Both servers are setup to us the Network Service account. The code is deployed to a physical disk on the servers. It attempts to write to a log file also on a local physical disk. The Network System user has full control permissions on the local directory. When the service starts, first thing it does is write an entry to the log file. This works fine on server A, but not on server B.
Can anyone give me a suggestion on where I might look for something that is actively denying file IO on IIS server?
The specific error message is Exception Details: System.IO.FileNotFoundException: Could not find file 'D:\Data\Logs\CDelivery.log'. I can assure you the file is in fact present, and this works just fine on server A.
P.S. I also tried this solution, but the IE Enhanced Security Configuration is already set to "OFF" for both Admins and Users IIS 7.5 App Pool write permissions denied

Found the problem. My code to writetolog is in a static class and I was accessing resources before locking them properly. Since the writetolog function is my generic error handler (among other things) the unhandled exception within it was causing w3pw.exe (and kernalbase.dll) to blow up.
Had to do a good bit of digging to find it because "Can't find file x" was not actually the problem at all. Terrible error message.

Related

HTTP 503 error when behind ZScaler corporate proxy and trying to access web app

A couple of days ago our web app started showing a 503 error when trying to access our web app. It works fine when ZScaler is off. This is an old app running .NET MVC 5 on a Windows Server 2012 machine. No changes were made from our side when the issue started happening, so I was suspecting that the networking team had done something. However, they cannot seem to locate the issue.
When trying to access the page through Chrome, I get a HTTP 503 error, but on Firefox it shows a blank page and says that the connection is not secure. I can access the web app through the server hostname URL fine. However, when trying to use the registered domain name, it is displaying this error. I have checked the logs on the server, but it isn't showing anything specific to this error.
Does anyone know what this could be? Is there anything in IIS that I should look at specifically?
I have checked the logs on the server, but it isn't showing anything specific to this error.
An HTTP 503 error usually indicates that the server is currently not able to handle the request due to maintenance or capacity issues. It could be caused due to many factors, like a server outage, an issue with the network, or a problem with the application itself.
Here are a few things you can try to troubleshoot the issue:
Check the IIS logs, IIS logs are located in the
C:\inetpub\logs\LogFiles folder by default.
Check the event logs, event logs can be accessed through the
Event Viewer (eventvwr.msc).
Try accessing the web app using the server's IP address instead of
the registered domain name. This can help determine if the issue is
related to the domain name or the server itself.
Make sure that the application pool for the web app is running and
that the application pool identity has the necessary permissions to
access the web app's files and resources.
Check the network configuration and make sure that the server is
properly connected to the network and that there are no issues with
the network connection.
Check the web.config to make sure that it is properly
set up and that there are no issues with the web.config file.
Check the ZScaler configuration to make sure that it is not
blocking access to the web app. You may need to work with the
networking team to determine if there are any issues with the
ZScaler configuration.

ASP.NET website deploys but only I can see

I have a prototype .net web site that is on Windows 10, created using C#. I am using IIS on the same machine to deploy from Visual Studio 2017. It uses SQL Server for back-end data. The site only runs on intranet.
It deploys ok, I can see all the pages, from all three of my machines. But others cannot see anything. They get a run-time error, that does not say anything specific.
My machine was re-imaged and hence the need to redo this.
I looked at IIS log and it does not have any info. What else I can look into?
In web.config, turn off custom error mode to see detailed error message on the client:
How to set web.config file to show full error message
If it works locally and not remotely, it's likely a permissions error (accessing a resource that the client doesn't have access to), or maybe a pathing issue (you are referring somewhere to something by disk or UNC instead of URL, or to a domain that only makes sense to you, like localhost).

C# Internal Server Error

I wrote a C# WCF server and I am trying to get it up in IIS but everything I try to go to my endpoint I get this error:
I checked the Permissions on the site and I have Authenticated Users others:
so I am not sure what to do now...
I imagine that the root of the problem is that you are trying to create an application on the server that points to files on your own computer using a Remote Desktop Connection drive share. The \\?\UNC\tsclient\C\... path is a dead giveaway.
This is a definite no. You cannot run a web service this way. The tsclient path is specific to your individual connection and will not work from any other context. Any other user account - including the service account that the IIS instance is running from - will not be able to access those files.
To resolve this issue you need to copy the files from your machine to a location on the server and recreate the IIS application entry, referencing the location on the server. You might still need to monkey with the security on the server-local folder.

Access denied to write a file with my C # WCF webService

I hosted a WCF web Service on my server Windows 2008 R2.
Everything works perfectly on my localhost project Visual Studio 2012.
However, once deployed on my server. My application throws an exception when my WCF trying to save an XML file in the C:\.
I immediately think it came from a permissions problem. I've tried adding rights in writings on the user IUSR but it changed nothing. I even tried to apply all the rights to the user "Everyone". But without success!
An idea ? thanks
Here's screenshots of on the configuration of my project:
Code that throws the exception:
XmlTextWriter myXmlTextWriter = new XmlTextWriter("c:/world.xml", null);
Why are you saving to the root drive folder? What happens when you try and save to for example C:\Stuff?
If this isn't running as something like Network Service I would hazard a guess it's because of something like UAC which will prevent you from writing to certain places considered restricted.

Reading Files On Network From IIS7.5

I have a WCF Service running on Windows Server 2008 R2 Enterprise. The IIS Version is 7.5. One of the methods in the service reads from a file on the network. It's failing when it tries to do this, but I can't log a proper error to find out why. My guess is that this is a permissions issue, but not being savvy with IIS, I don't know where to start.
The site running my service is using an App Pool with NetwrokService as the Identity. I have tried other built-in accounts, but I get the same problem. When looking at the running processes in Task Manager, I see w3wp.exe is running under the NetworkService account - which is how the App Pool is configured.
I'm trying to reach a share such as: \Machine1\SharedFiles\MyFile.txt. I can access this same share easily from file explorer so I know it's valid. Every other part of the service runs as expected which leads me to believe my IIS configuration is fine - other than possibly a permission setting that allows reading of files on other machines.
Anyone have any idea what I am doing wrong?
Thanks,
Start here:
http://learn.iis.net/page.aspx/624/application-pool-identities/
It is a permission issue. The share, and the files within it, need to grant access to the IIS servers machine account.

Categories