I'm using HttpPostedFile.SaveAs() in a Web API app. It fails to save with an access denied error if the file already exist.
From this post HttpPostedFileBase.SaveAs method question, that should not be the case. If I manually delete the file, all is well.
Is this issue related to permissions?
When I look in Explorer at the users who have permissions on this folder, there are four. Only my user doesn't have write permissions. I don't think that is the issue because otherwise, I wouldn't be able to write at all correct?
This is running on my dev machine.
It depends if the web app is running under IIS or IIS Express.
If your'e running from visual studio by default it on IIS Express, in that case the user is the user which ran Visual Studio (you). Be sure to run VS as administrator.
Under IIS the user is determand by the user running the Application pool which the app is attached to. By default a new special user is created for you which be named after the app-pool. You may change it at:
IIS-> Application Pool -> Right click the correct apppool -> advanced -> change the identity.
The easyest way to find out the actual user is to look at windows Task Manager (ctrl+shift+esc), go to Details, look for w3wp.exe and look at the username.
Related
I am using asp.net mvc 5 with c#. The app needs to create a folder in the server when certain action occur.
The folder has to be created in one network drive. All this works properly when the app is running in visual studio, however, doesn't work on IIS.
My guess is that the IIS does not have enough permissions, so i try to change the app pool identity, but the result wat the same.
Edited
One thing that could not help is that the network drive was created in the software in the server (QNAP server), not in windows.
How can i make IIS behave like visual studio ?
How about you create a virtual directory that maps to the nas share folder. Here are a few steps.
In IIS on your site right click and do "Add Virtual Directory"
In the dialog that pops up give some alias name and in the physical path enter the location to share folder.
Click the connect as button. In the pop up select specific user and then enter the credentials.
Now from your code you access virtual directory.
Hope that helps.
I'm running into a problem where UserSecrets returns my secret on Mac, but not windows. I followed https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?tabs=visual-studio
On windows, when I try to get the secret: Configuration["ConnectionStrings:Production"] it returns null.
I have the secrets.json file saved at C:\Users\username\AppData\Roaming\Microsoft\UserSecrets\<userSecretsId>
I can't figure out why it won't work on Windows, while it works perfectly on Mac. Any help is greatly appreciated.
It might be worth noting this is on a Windows Server
I'm wondering now if %AppData% is different in the context of IIS?
I think this thread is the right direction but none of the solutions work for me
The IIS ApplicationPoolIdentity should have it's own user profile folder, which is not the same as your user folder.
To find it, navigate to C:\Users, and you should see folders named for the application pools, so for an App Pool named ".NET v4.5" there should be a user folder called ".NET v4.5". Under that folder you should be able to follow the rest of your breadcrumb through the AppData folder and create the "\AppData\Roaming\Microsoft\UserSecrets" folder if it doesn't exist.
If that doesn't work or if you don't see user folders for the Application Pools, open up IIS Manager, select the Application Pool you're running under, then open Advanced Settings (link on the right hand side)
After opening the Advanced Settings, scroll down to the Process Model section and you should see a configuration for "Load User Profile", and make sure the value is set to True. Default is true in Windows 10, but depending on how you've done config prior versions of Windows defaulted to False which would make the secrets not available.
I have a problem with my web application. I develop using VS 2013 (run as Administrator) and Windows 8.
When I debug using IIS Express - everything works fine, without any errors (I run VS as Administrator). When I change project properties to use Local IIS (it's installed) - I cannot use external library which is placed in GAC (Microsoft.FlightSimulator.SimConnect). Also I run VS as Administrator.
Thrown error: "HRESULT E_FAIL has been returned from a call to a COM component" - this says nothing to me. This is thrown during creating new SimConnect object:
var simconnect = new SimConnect(...)
OFC, to use SimConnect, firstly Microsoft Flight Simulator should be launched (and it's started). This was proposed reason of the problem which I found in the Internet - second one was granting permissions (described below).
Details:
I have two projects in solution: library project (which is used to connect to the FSX) and web project (MVC - to present the results).
1) I tried to move whole library project content to the MVC project - nothing.
2) I used IIS manager to publish my website (with the seperate AppPool) - result the same as for Local IIS.
3) I granted permissions to the folder (where projects are placed) for my own AppPool and also for IUSR, IIS_IUSR and DefaultAppPool - full access. And nothing.
4) I ran FSX as Administrator - also nothing :/
I found the workaround: I moved the library project to the another project - console application where I used HttpSelfHostConfiguration to host that. And later, I call this api from the main project (MVC). For this solution everything works fine (I tested for Local IIS [debugging] and also for IIS Manager). I have to only run the Host Api project as Administrator.
I'm very curious what is the reason of the exception. And additionally: how to resolve that :)
It seems like the problem with the permissions - but I granted to the every used AppPool.
Can be the reason lack of permissions for dll in GAC? I don't think so, but I have no idea what to do. If yes, how to grant permissions for dll in GAC (or how to copy that)?
#Krzyrok, Had the same issue recently on my one of my projects where I used external libraries. After following endless crumbs I got it resolved. Change your application pool identity from "ApplicationPoolIdentity" to "LocalSystem". I also changed the sites Anonymous Authentication to "Application pool identity" from the specified IUSR but tested it and it can be left on IUSR. I also granted permissions to the folder for IUSR and IIS_IUSR.
If someone comes across this problem, it is possible that the problem is that you have not configured SSL for your localhost site. The site might be trying to communicate via https port 443 and it cannot find the site there. The site may be hosted only on the unsecure http port. To solve this problem,
Go to IIS Manager
Right Click on the Website
Click on Bindings on the right
Click on Add
Select https
Select the IIS Express certificate
Click OK
I was using the physical path of the \bin folder as the basic settings physical path of the web site in IIS. I forgot I had to publish the web service and use the publish path as the basic settings physical path of the IIS website.
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.
I am trying to publish a website using IIS, I made a virtual directory and in this directory I've added all the webpages and configured the virtual directory but still I am not able to run my web application.
Here is the step by step method to deploy an asp.net application
http://www.15seconds.com/issue/030806.htm
Please post any error message
Make sure that your are running the right asp.net Version...
check if in the asp.net tab if it's v 1 change it to v2
Could you please let me know the error message.( Check with minimum settings like startUp page , version, try publishing with Wizards etc)
In Visual studio, click on project, Properties, Web.
Under Servers, select Use local IIS Web server, then on Create virtual Directory.
Now, when you debug, the page should open in IIS, and Visual studio has taken care of most of the grudge work of setting up the IIS, all you will probably have to change is the security settings under IIS. Hope this helps.
If it is IIS7 check that your application has enough permissions to run:
IIS Actions Pane:
Basic Settings
Connect as (be sure to log in with Admin account first to test, then create you own specific user. Least Privilege Principle)
Test Settings (Authorization and Authentication is Green!)
Test your webisite
The question doesn't say what exactly the error is but you mentioned that you just created the virtual directory. Did you make it an web application? For IIS 6 follow this
link - Create and Configure Local ASP.NET Web Sites. In IIS7 just right click on it and convert it to application.
If its already a website, did you choose the correct framework? normally when you create a website it ill be assigned the default app-pool. If you have installed multiple dotnet then you might check which framework is in default app-pool. Then change the default app-pool to the correct version that is required by your website, or create a new app-pool.
There can be multiple reasons so if you could provide the error message then it would be easier to resolve the problem.
Thanks.