Acces Denied - Generating a directory in Microsoft Server with Silverlight - c#

I have searched the internet and cannot seem to find the answer to my question. I have also searched thoroughly through stackoverflow, which might help me to pose a better question.
I have made an application with webservices in C#, which is running in Silverlight.
My problem is that the application has to create a directory with a relative path. Locally it works, but when I upload it to Microsoft Server it does not create a directory.
It says the following:
File operation not permitted. Acces to path: 'c:/inetpub/wwwroot/...' is denied.
I use this line of code for the creation:
Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath("TEMP/");
On the map where the application is running, I have granted all rights to public and IIS user. But it still gives the same error. Besides this, I have also wrote a small piece of independent code in .Net to create a directory. This was to test the access and that works.
So I don't really know where to look.
#Update - 22/05/2014 - 14:29
I have literally deleted all code and just kept a create directory function with one button and one event handler:
Directory.CreateDirectory("path");
I have noticed that relative path's do not work in Silverlight here. (He seems to think the path the browser(i.e. Chrome) as being the parent and not the application's path).
Some other findings are, that if I put in the absolute path. Locally it works, but when i upload it to the server it again says acces denied...
Any tips are very welcome!

I have found the solution to the problem!
The following was going wrong:
My silverlight application consists of two parts. A Web-service and a Client;
The Web-service executes as being the user: IUSR, which had the full rights on the server.
The Client executes as being the user: DefaultAppPool.
The problem with this, is that the DefaultAppPool user can not be given rights as easily. If you try to give rights the default way, in the map settings, the DefaultAppPool user cannot be found.
The correct way to give full rights to DefaultAppPool, is to go to the command console and type:
icacls c:\"Path to the map" /grant “IIS APPPOOL\DefaultAppPool”:(F)
For more detailed information about this, check the following link:
http://eufuckingreka.wordpress.com/2013/02/12/granting-defaultapppool-permissions-to-a-direction-on-windows-server-2008/

Related

Getting error while running ASP.NET Website on Local Host Server

I'm running a web application developed on ASP.NET; C# and SQL Server 2008; on Local Host on a Network.
It is showing an error 500.19 for some Permissions...
Can anyone help me out to solve this and run my website on localhost without hosting it online.....Have a look, What's the error is...
It might be the issue of permissions for the directory/files for your application.
Make sure you have given the full permission to the users types that will be accessing the application.
For adding/editing permissions, you can navigate to the concerned folder and right click on it, selec properties and then go to security tab wherein you can edit the permissions of existing users as well as add new users with specific permissions.
Also, if you have your application hosted on IIS, there is also an option for changing permissions which will again, open the folder for you and you will have to follow the same steps as mentioned above.
Hope this helps.
Such issue occurs when, some wrong or duplicate element added in web.config file.
Verify your web.config file.
Also confirm execute version of virtual directory (32 Bit / 64 Bit)

SharePoint Network Share Access Denied

I'm building a web part for our SharePoint that needs to read file and folder names from a network share. However, I get an access denied error when I try to use
Directory.GetDirectories(path);
I've done some research on how to fix this, the general consensus is to either use RunWithElevatedPrivileges or impersonate the current logged in user. Unfortunately everything I've tried has failed. I have tried all of the following to no avail:
Impersonating the user and here
Setting the ASP.NET app pool to classic mode (Breaks all of sharepoint)
Changing the trust level for SharePoint to full (Doesn't seem to affect anything)
Giving the Network Service permission to the network share
Making a symbolic link on the SharePoint machine that points to the network share
Any suggestions on what to do? I'm at the end of my rope.

Unable To Access File In IIS 6 Virtual Folder From Web Application

I have a website sitting in a virtual directory in IIS 6.0. Within this virtual diretory there is also a P12 certification that I need to use for accessing an external web service. When I attempt to access this file through the site, I get a "file not found" error.
I have verified that the file is there and have mirrored my local dev enviromnent to match production and all works fine there.
I'm pretty confident that this is a permissions issue.
Can anyone point me in the right direction?
Thanks!
By default, IIS 6 will only serve specific types of files (based on extension) to requesting clients. If you're P12 certification (I'm not sure what that is) file is not one of those, a 404 is exactly what you should receive.
In your IIS admin console, you can modify the list of file types which are processed and/or served.
It sounds like it's possible you're attempting to access this file programmatically, in which case you'll need to provide a bit more information - show us the code that is attempting to access the file, and maybe the exception as well
EDIT:
Based on your comments about the location of the file, you could try doing something along the lines of this:
File.Exists(Server.MapPath("/") + "DLWSCert.p12")
I found that the message of the exception is misleading. The message says was File Not Found but the message was contained within a System.CryptogrphyException. Ultimately, the problem was permissions on the app pool account. Once those were set properly, it worked fine.

Downloading from website error - Could not find a part of the path

I am trying to create a quick fix for a problem I am having. All I need to do is download a file from my website to a local computer.
I have a website using ASP.NET and C# and I have added the code below to a button click to download a file:
WebClient webClient = new WebClient();
webClient.DownloadFile("http://www.mysite.com/myfile.ext", #"C:\test\myfile.ext");
which produces the error in the title:
Could not find a part of the path 'C:\test\myfile.ext'.
The directory does exist on my computer.
From what I have read this appears to be a permissions issue on the local computer. I have added full permissions on that directory for the NETWORK SERVICE user as I am running Windows 7. I also have a user that is running XP so I believe the user there would be ASPNET.
Needless to say none of this has worked and allowed me to download the file. I'm a little out of my element here so I'm not sure what to do. It could be that I'm on the right track and just missed something obvious, or maybe I'm way off base.
Anyone have some guidance for me?
EDIT
The more I think about this, I can't help but think there's a better way to do this.
I've downloaded from websites before without ever needing to deal with permissions, so what would be a better simple approach? What am I missing here?
ANSWER
Thanks, I found exactly what I needed from Hari's responses below.
The user running the application pool used by your website needs to be given permissions to read that file. So, goto IIS > app pools > find the one for your website > the one that's under identity.
Check the application pool identity type to make sure you are granting permission to the correct user, see this website for more details.

Could any one explain me why this error was occuring while doing in IO operations?

I have a small windows app which was given in this article.
In this I want to to compress a sample.txt file.
But am getting this error:
"Access to the path 'C:\Documents and Settings\hemanth.vemu\Desktop\Compress' is denied."
Please help me regarding this.
It means exactly what it says.
The account that the application is running under does not have the right permissions on the folder in question.
Make sure you have read/write/create permissions on the folder you are working with.
You will need to give your application authentication to the hemanth.vemu user. You can use LogonUser to do this. It can validate both local and remote users. For local users simply pass the machine name in place of the domain.

Categories