ASP.NET Core Accessing Folders Outside Inetpub - c#

I have a ASP.NET Core Web app, the issue I'm experiencing when I deployed on the test server is accessing two folders outside of Inetpub:
C:\Directory\ineedthisone and C:\Directory\ineedthisonetoo. I get Access to path C:\Directory\ineedthisone is denied. I've tried giving permissions to the folder but i still get the same response. Am i missing something?

Related

Can you host a blazor app on IIS in a sub folder?

I have the basic blazor project that im trying to host in a specific way. I have managed to host the app in IIS where all the files were in the same folder. The issue im having is the web config in the root folder and then having the actual app itself in a subfolder.
IIS app file structure
im using blazor server which is sitting the "test" folder.
test folder where the blazor app is, seperate to the web config
Is this even possible to host in this way? or is there routing or config that needs to be done to get it to work?
Thanks,
So far I'm afraid it is unavailable to host application in site level. No matter I set the aspnet core handler in root level or folder level, change location value,change processPath. IIS just ignore the attribute even I have set it in both root level and folder level.
I think even you were able to host blazor in a sub-folder, Duplicate attribute verification is easy to crash the application when you need to publish something in root folder.
So the best way to handle this is convert test folder to an application. Then everything get isolated and start working.
interesting idea
I see no reason, why not to create a sub directory as website in iis. There have to be a extra app pool unmanaged for each.

How to access files from network path on .net core 3.1?

I want to access files from a networkpath (\172.x.x.x\I$).The files should not be served staticly, they should only be accessisble through code.
When accessing a file directly I get an UnauthorizedAccessException: access to path denied.
What are my options here? Adding a virtual directory seems like a good idea here. But I'm stuck trying to access the virtual directory from .net core(3.1).

Do we need a Virtual Directory for WebService

I have selected an Empty ASP.NET WebApp just to add a simple WebService 1.1 to in.
I can run my web service and see it working in the IE browser so my question is what is Virtual Directory for and do I even need it?
You don't need to have a virtual directory or a web application specific to your webservice. However, consider that your ASP.NET website or webservice is an application and requires an application pool to run in within IIS (or Cassini). Therefore, you need to make either the folder containing the webservice files or its parent a web application.
For example:
if your web service is hosted in such a disk folder:
C:\Inetpub\Wwwroot\Foo\Folder1\WebService\ASMX\MyGreatService.asmx
Any of these levels could be a web application:
C:\Inetpub\Wwwroot\Foo\Folder1\WebService\ASMX\
C:\Inetpub\Wwwroot\Foo\Folder1\WebService\
C:\Inetpub\Wwwroot\Foo\Folder1\
C:\Inetpub\Wwwroot\Foo\
(you get the picture...)
If you are doing this through IIS, when you create your website in IIS, it will automatically turn your top level directory into a web application. For example, if you create a website with its root folder at C:\Inetpub\Wwwroot\Foo\, that folder will already be a web application for you. To change any particular subfolder into its own web application, simply right-click on the folder you want to convert and select "Convert to Application".
For more details, I would refer you to the following articles:
IIS: Understanding Sites, Applications and Virtual Directories
IIS 7.0: Create and configure Virtual Directories
Web Application Vs. Virtual Directory

IIS 7.5 Directory Access Denied When File.Copy

When i try to copy files with System.IO.File.Copy() with ASP.Net C# in IIS 7.5 i get directory access denied error.
I've added almost every possible users that could need a permission on that folder :
IIS APPPOOL.Net v4.5 Classic
IUSR
IIS_IUSRS
Didn't work. I've then added same permissions to the parent folder , but i still can't make it work.
PS : I don't use the inetpub directory for this application. It doesn't even located in the system partition (e.g. C:\) . Its in somewhere else and its sync with Google Drive. But i can travel through files with these permissions.
So what do you all think it could be ?
Use FileMon to identify the exact account that is trying to copy the files and getting the access denied error.
once you identify the account, give necessary permissions to it, instead of giving access to random accounts which could result in security issues.

How to access folder in network which outside from project in MVC 4.0 ASP.NET?

One of my folder is reside in local network or local machine for upload and display attachments. I can not manage (upload or display) this in MVC 4.0, ASP.NET. For that I wrote path in appsetting of web.config. Please guide me how to manage it.
Simply having the path recorded and used does not mean that the application has the permissions to access it.
You need to ensure that the account that the web application runs under has the permissions to access this folder (the account details will be in the properties of the web server application pool that is setup for the site).
try to:
create a Site mapped on your attachments folder
In your project, add two AppSettings: AttachmentAbsoluteUrl, AttachmentFullname
When you have to download an attachment, you can use the Url defined in the AttachmentAbsoluteUrl AppSettings Key, when you have to upload/delete/add, use the AttachmentFullname key.
In this way you can manage both development and production environments, using different AppSettings values.
For example, in my local computer, I have the Attachments folder in the same directory of the project, in production server, I have a different folder outside the Site directory.
You have to check if the Identity of the Application Pool used by your Web application have the rights to modify the contents of the Attachments folder.
I hope this can help you

Categories

Resources