Access to the path is denied - asp.net-mvc

i make simple application to sending email to my localhost.
in windows 7, my application can run correctly, but when i try to debug and running in windows 8, my application give me some error like this
Access to the path 'C:\604ea33a-0b6c-4b47-8e4e-5ff9ff3c35a8.eml' is denied.
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.
can some one tell me, whats wrong with my code?
thanks

I Change my path directory to C:/Windows/Temp
and run correctly in windows 8

You must be getting UnauthorizedAccessException .The exception that is thrown when the operating system denies access because of an I/O error or a specific type of security error.
It is clearly a permission issue.
In case of Vista/Windows 7/8, C:\ drive is considered as system drive, and need administrator privileges for your process in order to create files directly under it.
Try running your process with administrator or Run Visual Studio as Administrator, and it should work.

Related

Visual studio project in samba network drive results in IIS express permission denied

I have created a ASP.NET Web Application project. When I click the "IIS express" button in Visual Studio I get the following in the browser:
Access is denied.
Description: An error occurred while accessing the resources required to serve this request. You might not have permission to view the requested resources.
Error message 401.3: You do not have permission to view this directory or page using the credentials you supplied (access denied due to Access Control Lists). Ask the Web server's administrator to give you access to 'H:\mypath'.
If I move my project to somewhere on C: then everything works as expected.
H: is mapped to a samba share on a Linux host.
I believe that IIS express is expected to run as the current user when started like this, so in that case the samba credentials should not be the problem.
So...how do I solve this problem?

TFS Release, running PowerShell, cannot create DtlDownloads

I am trying to get some automatic deployments up and running using TFS 15 (on-premise). I have a powershell script on the deployment target to call.
The deployments starts fine by downloading the artifact. But when the agent runs the script it wants to create a folder C:\Windows\DtlDownloads (thats not part of my script but part of preparing things for TFS I guess). That fails:
##[debug]System.AggregateException: Failed to install 'VisualStudioRemoteDeployer20597940-38b2-4ba8-9a4d-fcc894308730' from service executable path VisualStudioRemoteDeployer.exe . Consult the logs below:
Access to the path 'DtlDownloads' is denied.
CategoryInfo :PermissionDenied: (C:\Windows\DtlDownloads:String) [New-Item], UnauthorizedAccessException
FullyQualifiedErrorId :CreateDirectoryUnauthorizedAccessError,Microsoft.PowerShell.Commands.NewItemCommand
The user used to logon is a server-local user named deploy who is also a local administrator on that machine. I also checked the effective access for that user on the windows folder and it should be able to create directories.
Something similar happens with the copy step. Robocopy signals two errors:
2017/03/16 08:57:21 ERROR 5 (0x00000005) Getting File System Type of Destination \\server.domain.com\c$\abc\def\
Access is denied.
and
2017/03/16 08:57:21 ERROR 5 (0x00000005) Creating Destination Directory \\server.domain.com\c$\abc\def\
Access is denied.
The second is a bit unexpected as the folder def already exists but I guess it is a follow up because getting the type failed beforehand.
The user itself must have been recognized because I get different errors when using invalid credentials. I have enabled WinRM using Enable-PSRemoting and ConfigureWinRM.ps1 from WinRM-Http-Https-Without-Makecert.
What could still restrict the permissions?
Update: Using a domain user instead of a local one of that server solves the issue. But I do not understand why. Can someone explain or even provide information how to make it work with a local user?
The username of either a domain or a local administrative account on
the target host(s).
Formats such as username, domain\username, machine-name\username, and .\username are supported.
UPN formats such as username#domain.com and built-in system accounts such as NT Authority\System are not supported.
Source Link
Both the domain account and local admin should be work. Please double check your format and give a try with another format.
One problem could be if that you have the agent as a service, that service has not the proper privileges, like being on Network Account. Try to change that to the user account which has administrative privileges.
Running "winrm quickconfig" fixed this problem for me
winrm quickconfig
https://learn.microsoft.com/en-us/windows/win32/winrm/installation-and-configuration-for-windows-remote-management

Getting error "Unable to attach to the process. The address is not valid for this context" while attaching process for debugging

I am trying to host my ASP.Net MVC application on my local IIS 7 and debugging it. For this I host my application on IIS 7 and run application from it. When I am accessing my application from browser I am able to access it and it's working fine. Now for debugging I started my application in browser from IIS and in my VS2012 try to attach to process and select w3wp.exe it not allowing me to attach process for debugging and showing error message as
Unable to attach to the process. The address is not valid for this context
I tried to run VS2012 in administrator mode too but it won't help. Please tell me what I am doing wrong
Thanks in advance...

"Access to Message Queuing system is denied" exception in console application

I have an application that can run both as windows service or stand-alone console. It is deployed remotely, on my client's servers. When I remote desktop into the server, I use the same domain account that is used to run the windows service configuration of my application. Therefore, running the application as windows service or console is done absolutely under the same credentials. Or is it? The problem is that my console throws the "Access to Message Queuing system is denied" exception while the windows service doesn't have any issues with this. All the functionality of the application that accesses the MSMQ system is encapsulated into a .dll that is used by both the windows service and the console, so again, there should be no difference.
Any ideas as to what should I change?
I made a Windows Service that interact with MSMQ (a stupid data exchange application with no requirement regarding security).
I had to disable un-authenticated RPC calls using the Message Queuing properties pane in Computer management to make it work. Otherwise it throws System.Messaging.MessageQueueException (0x80004005): Access to Message Queuing system is denied.
Also the service run under Local System (which I remember is by default)
The user under which the service/console is executing should have access to MSMQ.
Please check if this is the case or not in your instance.

WMI Security error TF255437 when installing TFS 2010 RC

Does anyone know the resolution to the following error. In this scenario, TFS will be using a local report server instance which points uses a separate SQL Server database engine instance.
An error occurred while querying the
Windows Management Instrumentation
(WMI) interface on the following
computer databaseServer. The
following error message was received:
Access is denied. (Exception from
HRESULT: 0x80070005 (E_ACCESSDENIED)).
You can grant the priveleges temporarily at install time and then remove them. I had the same issue and that appears to be the only solution.

Resources