Related
I am using Microsoft Visual Studio 2015, I built a simple website with a C# contact form.
When I compile and run on localhost it works perfectly fine. However, when I try to publish it (on smarterasp.net) I am getting an error:
[Win32Exception (0x80004005): Access is denied]
[ExternalException (0x80004005): Cannot execute a program. The command being executed was "..\bin\roslyn\csc.exe"
I have contacted smarterasp.net and they said they dont allow .exe files. I tried to delete csc.exe with ftp from the server but when I do that I am getting the error:
Could not find file "..\bin\roslyn\csc.exe".
How can I solve this issue with the csc.exe that is trying to get included in my project so I can get my this website published?
After hours of researching i came up with the solution.
Since the .NET 4.5 version, Roslyn compilation is the default way of compiling. This means if you create any web application either Web Forms or MVC using .NET 4.5 you get this Roslyn csc.exe compilation pre-installed in your project.
Basically what i needed was to compile and deploy my project without Roslyn or any .exe files on it.
So here is the Solution that worked for me. You can deploy without Roslyn with no change in code:
Open NuGet Package Manager window
uninstall Microsoft.CodeDom.Providers.DotNetCompilerPlatform package and rebuild & republish. (This uninstallation also removes CodeDom configuration from web.config file.)
This will solve your purpose. Basically this will not generate any csc.exe, vbc.exe files inside bin folder.
I hope it works for you too!
I had this issue on Smarter ASP. On the browser file manager in the control panel, navigate to 'Roslyn' folder in bin and set .net permission to read/write. It worked then.
If you actually want to keep the roslyn codegen, you just need to set the permissions on the application's bin folder to allow the ApplicationPool user Read & Execute.
I did this using the explorer Security tab on the folder properties dialog, but you should also be able to do something like:
icacls PATH_TO_SERVICE_BIN /grant "ApplicationPoolUser":(OI)(CI)RX
I found the solution as unchecking "Allow precompiled site to be updatable", on publish window.
Just remove the codedom section from the Web.config, this solves the problem.
Just set rw access for /bin folder in Smarterasp.net File Manager as shown below, restart your app
Just experienced the same issue as the OP when publishing an ASP.net 4.5.2 SPA via web deploy in VS2015.
The solution I found to work was to remove the Nuget package "Microsoft.CodeDom.Providers.DotNetCompilerPlatform".
You could, alternatively, simply remove the system.codedom compiler config section from your Web.config file, which would have the same affect.
Here's how I got it working:
In your control panel, navigate to Security Manager > Allow .EXE Files
Set the value to On (this will let you upload .exe files)
In your Web.config, set full trust (this will let you run them)
<configuration>
<system.web>
<trust level="Full" />
</system.web>
</configuration>
In your publish settings, enable "Precompile during publishing", but in the
Advanced Precompile Settings (the Configure link next to this option), disable "Allow precompiled site to be updateable".
I had the same error and I solved it by enable the permissions of the hosting directory (read/write/delete).
If you need SmarterAsp.Net to allow the uploading of an .exe file to support the features and functionality of your website, you can. Just go to the control panel and turn on "Allow .Exe Files" See below:
In my case I had to do this because I wanted to host an Asp.Net Core website and that absolutely requires an .exe file :-)
tl;dr: Ensure that csc.exe is not zero bytes in size.
Longer answer
To add yet another cause and solution: In my case, I got this Yellow Screen Of Death in my browser:
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.
Compiler Error Message: The compiler failed with error code 255.
c:\windows\system32\inetsrv>C:\inetpub\wwwroot\bin\roslyn\csc.exe
/t:library /utf8output /nostdlib+ ...
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.7.2558.0
Upon investigation, I isolated the call to csc.exe by executing it inside a CMD window:
c:\inetpub\wwwroot\bin\roslyn\csc.exe
I got this message box:
followed by this line in the CMD window:
Access is denied.
Upon inspecting the files in Windows File Explorer I found out that csc.exe had a size of zero bytes.
I'm unsure at which stage of my deployment script this happens, but after replacing the 0-byte-sized csc.exe with an actual working one, everything works correctly.
The above solutions did not work for me and are not correct, since roslyn is not optional these days.
What worked was ensuring that the pool account had read & execute permissions on the root folder of the web application. You can find the account to grant this permission to by finding the Pool name your web app uses, then Application Pool -> pool name -> Advanced Settings -> Identity.
My VPS host uses non-standard directories for hosting as follows:
c:\home\web.app.name\wwwroot
The web.app.name folder needed the permission.
Updating the nuget package Microsoft.CodeDom.Providers.DotNetCompilerPlatform to the latest version (at that time) 2.0.1 resolved this issue for me without having to grant permissions to the folder or remove the compiler.
We encountered this due to a 3rd party application. MalwareBytes Anti-Ransomeware was actually the culprit that was blocking access. Resolved this with:
Right-click systray icon for MalwareBytes Anti-Ransomeware (not anti-exploit)
Stop Protection
My web application is just a simple web application made in VS 2010 MVC 4 without any code from outside. It's just default application of VS 2010. I have Deluxe Windows Hosting with Plesk. I've never changed any feature in my account. I copy all my files to "//Root Directory". Beside my files I see various folderssuch as: ", plesk, erro-docs, cgi-bin, logs" - I do not have permissions to delete them.
All my projects are "Release" configuration. I've tried all ways which I met in the Internet:
1.I copied three libraries to bin directory:
System.Web.Mvc, System.Web.Routing, System.Web.Abstractions
These dll's I copied from GAC(C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL). I putted such strings in web.config: < trust level="Medium"/>. I used local deployment(to directory) in VS2010 by button "Publish". No result.
2.I copied 9 libraries to bin directory:
System.Web.Abstractions.dll
System.Web.Helpers.dll
System.Web.Mvc.dll
System.Web.Optimization.dll
System.Web.Razor.dll
System.Web.Routing.dll
System.Web.WebPages.Deployment.dll
System.Web.WebPages.dll
System.Web.WebPages.Razor.dll.
These dll's I copied from GAC(C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL). I used local deployment(to directory) in VS2010 by button "Publish". I putted such strings: < trust level="Medium"/>. No result.
3.I copied three libraries to bin directory: System.Web.Mvc, System.Web.Routing, System.Web.Abstractions - these dll's I copied from GAC(C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL). I putted such strings: < trust level="Medium"/>. I used deployment via ftp option in VS2010 by button "Publish". No result.
4.I copied three libraries to bin directory:
System.Web.Abstractions.dll
System.Web.Helpers.dll
System.Web.Mvc.dll
System.Web.Optimization.dll
System.Web.Razor.dll
System.Web.Routing.dll
System.Web.WebPages.Deployment.dll
System.Web.WebPages.dll
System.Web.WebPages.Razor.dll - these dll's I copied from GAC(C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL). I putted such strings: < trust level="Medium"/>. I used deployment via ftp in VS2010 by button "Publish" No result.
5.I've tried to upload files via filezzilla. < trust level="Medium"/>. However it was an idle attempt.
6.I've tried to upload files via browsers. However it was an idle attempt.
7.I've tried to upload zip-files via browser and extract them at godaddy server. < trust level="Medium"/>. However it was an idle attempt.
All above-listed attempts result the word on the screen: "nup.com My site is launching soon."
Nothing changes.
I have a question.
What I do wrong?
I've read all articles by Phil Haack http://haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx. Any help will be gratefully appreciated!:)
Ok - you have a lot of questions inside your single question. I am going to try and take these one at a time as well as some of your commentary so that we can a) understand the build/publish process of an MVC app and b) hopefully get your project running over at GoDaddy.
1.If I change in web.config , then should I recompile my project and upload again?
No, unless you change the web.config locally and you need to upload those changes. If you FTP/connect to the web.config on the actual web server, IIS will automatically restart (reload) your application so that it can apply the web.config changes. After a web.config change, you will notice the first request will take 10-20 seconds. This is IIS restarting your application. If you change the web.config locally, then yes, you should rebuild/reupload.
2.Is it correct to copy a project to root of directory?
The way you have phrased this question makes me think that yes, you are doing it wrong. When you create a project in Visual Studio, you get a solution folder on your actual hard drive. If you are compiling that project, then copying the entire solution folder to your web server, then yes, this is not the correct way to do it. What you want to do is create a Publishing Profile. You can either deploy your application via Web Deploy (unsure if GoDaddy supports this), FTP, or File System. By going through the Visual Studio publishing process, the compiler a) compiles your application per your settings (Debug or Release), b) applies the proper Web.Config transformations and c) only outputs the files necessary to run your application. The third part is important. All of your .cs files (controllers, models, etc) get compiled into a .dll and that is what needs to be deployed, not the actual source code files. The publishing process does this for you.
I would recommend you create a folder on your dev machine somewhere, and then create a publishing profile that publishes your application to that folder. It is the contents of that folder that you want to FTP to your web server. To create a publishing profile, right click your MVC project and select Publish. This will bring up the wizard for you to set things up.
3.What I do wrong?
Kind of hard to say at this point. It could be that you are not compiling your application correctly. FTP sounds bonked, but that is not an MVC/Visual Studio issue. For FTP issues with Plesk on GoDaddy (and other items), check this help link here.
4.how can I see the errors? Should I write a message or what should I do to know more about errors?
You should be able to control this in your web.config. Open your web.config file up and check for a couple of lines. You want to turn off custom errors and set the compilation to debug mode. This does two things. One, the error you get back from the server will be way more detailed and being in debug mode allows IIS/.NET to actually show you the line of code that is causing the problem.
<system.web>
<compilation debug="true" targetFramework="4.5" />
<customErrors mode="Off"></customErrors>
</system.web>
Be aware that if you do have a web.config transformation, this could actually turn these setting off. Ensure that your publishing profile is set to deploy the Debug configuration while you test deploying your site. Once you are happy with your results, set it back to Release configuration so that your site runs faster as well as does not display code lines to potentially bad people if an error does occur.
5.I copied 9 libraries to bin directory...
Ok, this could also be a problem. You do not need to copy anything to your bin directory. If you want to include referenced assemblies in your published project, all you need to do is open the References folder under your project. From there, right click any assembly that you want to include in your project when you publish and select Properties. Inside of the properties pane, you will see the option to Copy Local. Set this to true. This tells the compiler to copy that assembly to the output folder during the publishing process (see, that publishing thing does lots of good stuff for you!) I would do this for all assemblies in your project that are MVC related. You can experiment with this (like one at a time) until you find the right combination of assemblies that you need to include in your project to make it run on the GoDaddy server. I have not used GoDaddy hosting in quite a while, so I do not know what their current capabilities are.
Last thoughts, I think MVC 4 is .NET 4 or higher. Ensure that GoDaddy supports .NET 4 or higher or else you really won't be able to host this on that server (even using bin deploy) and will need to find additional hosting. Azure has some really great deals right now and Gearhost is very reliable but a little pricey (though they are completely simple to use).
EDIT
Just a little more info on GoDaddy - ensure that you set your site up correctly before you try any of this. You need to have Windows hosting (most likely) and it should be setup to use the Integrated App pool (else, it would appear you never uploaded anything since there is no 'default document'). At this point, I wonder if your hosting account was provisioned correctly for what you want to do. http://support.godaddy.com/help/article/6639/do-your-hosting-accounts-support-mvc3-applications (Yes, I know it says MVC 3, but the setup applies equally to MVC 4)
Have you tried bin deploying MVC4?
http://haacked.com/archive/2011/05/25/bin-deploying-asp-net-mvc-3.aspx/
or
http://forums.asp.net/t/1884928.aspx
To answer your question:
Changes to web.config should not require the project to be recompiled.
Hope this helps...
Depends what you've changed, some changes might at least require an application pool reset.
Root of what directory? It should generally be inside inetpub/YOURWEBSITEFOLDERHERE
You have assumed that GoDaddy supports MVC 4, I could only find references to them supporting MVC 3 Support
There are rumours that if you deploy the bin and mvc dll there is a way around this but I couldn't find any details.
Have a read of the MVC 3 deploy instructions
EDIT: In answer to comment below:
Editing could have a knock on effect and so i would advise towards a recompile, e.g. change to medium trust might have an affect if DLLs don't work in partial trust mode, and recompilation might well highlight these issues.
Sounds ok, test by putting a html file up with some text and try and get to it in your browser.
I've seen people talking about it, mostly saying it's not supported, try the MVC deploy instructions above to bin deploy MVC 4; it works with 3, it might work with 4.
I had the same problem with a MVC4 I had running on hosting on Godaddy using Plesk. Suddenly, without any changes, site began to display "Site Launching Soon" Page. At first I thought it was hacked. After calling godaddy support, the agent told me that the site must need at least one html file as a start point (index.html, index.aspx, default.aspx - source: http://support.godaddy.com/help/article/60/what-file-displays-when-someone-browses-to-my-domain-name?locale=en&ci=46061), which seemed odd because it was working fine all the time.
Then, after some trial - error stuff, I could solve my problem by going to the Plesk hosting management, and navigate to:
Websites & Domains > [domain name] > Web Server Settings for domain. And there, change the Default Document setting to "Default".
We never touched that setting, not sure really why it suddenly changed.
Hope that helps!
Hope this helps . . .
Global.asax should be your default index . . . in godaddy server settings.
I had a similar problem and was able to solve it.
I have two other mvc application sites hosted on godaddy, but not with their new plesk hosting.
After calling tech support and not having any luck there I did some reading on their hosting.
Their plesk hosting must have an index.
So, a few hours later it dawned on me to point their start point to my Global.asax in their server settings.
And, viola! my site was up and running.
I've done all actions to deploy correctly but I copied all files to a wrong folder. The problem was that I just copied all my files to a wrong directory. I called to godaddy support and they said that I copied my files to wrong directory.
When I copied all files to "httpdocs" directory then my mvc 4 application start working!:).
Thank you a lot, guys. Good luck.
I was having the same issue until I set customErrors to off (first line). then I started seeing security policy issues which was remedied (second line).
(I'm using Godaddy)
I am facing a problem for running my website.
I have developed the website and when i hit F5 to view the results i am presented with this error
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
How can i solve this problem.
This error usually happens if you Map your application folder on Network Drive or open Solution file from UNC Path. somthing like this:
Invalid Example: \\my-server\my-project
Try to open your solution from direct path
Valid Example: C:\Project\MyProject
You can also make change to your privilege of App Pool Identity but it's not recommanded:
Web Server (IIS) > App Pool Identity > Advance Settings > Set Identity as Network Service
the one shot solution worked for me was to set the App Pool Identity(Advance Settings) to Network Service
Try to set "Load User Profile" value of your application pool to "True".
It worked for me.
For what its worth, I found that the AjaxControlKit.dll on the deployed server was blocked. To resolve this, I copied over the dll to a new folder then copied and pasted in the bin folder. I guess .net doesn't like a dll being copied over directly to the web folder
you can run the following command to Grant FullTrust to remote share:
C:\Windows\Microsoft.NET\Framework\v2.0.50727>caspol.exe -m -ag 1 -url
"file:////\yourcomputername\yoursharename*" FullTrust -exclusive on
Hope this helps.
I tried all of the solutions posted here and a number of other places and nothing worked for me. I had my project located on a network drive which worked until I tried to use the AjaxControlToolkit 2.0 in my project. Apparently, something about permissions on the network drive would not allow the controls in the toolkit to run. I moved my project back to my local hard drive and it all started working.
I had this problem as well but have not seen this particular solution mentioned anywhere.
After checking permissions for the IIS user, the user for Impersonation, and granting Full Trust to the application, and still getting the error, I installed Procmon.exe on the server running IIS and noticed that IIS was attempting to access some Framework64 files for the offending website. I inspected the application pool advanced settings and discovered that "enable 32-bit applications" was set to false. Changing this setting to true proved to be the correct action. Life is good.
I face the same problem, then I realised that I was running the solution from a remote folder. Copy the necessary file to the local folder will solve the issue. But make sure that your folder have the full permission
While all of the other answers on this page may be the cause of anyone's problem, the most common one is due to OS security changes in Windows Server 2012 and above. Any file downloaded from the internet is flagged as suspicious by Windows and needs to be manually unblocked before using it in IIS. So if you FTP your code, email it, or transfer it through a cloud provider, it will be flagged and blocked.
The best solution is to use the web publishing facilities built in to Visual Studio or transfer through a network share if you're on a domain, each of which avoid this problem. However, if you must copy your code to another server by one of the means I described above, you should zip everything prior to transfer so you are only left with a single file to unblock. If you unzip before you unblock, then each file will be blocked and multi-selection will not give you the option to unblock.
So finally... to unblock: Right click the file and select Properties. Right there on the first page near the bottom you'll see an Unblock button along with the warning that the file was downloaded from the internet!
If the dll is compiled using this option (Do not merge. Create a separate assembly for each page and control), please make sure the dll is up to date. I faced the error due to aspx file is new one, but dll still using old one.
I found a potential solution that worked on my system and did not require changing to Network Service.
Go to Application Pool -> Advanced Settings -> Process Model -> Load User Profile: True
Source of this answer.
The best way to resolve this issue is Run the Visual Studio as "Administator". Right click on the Visual Studio icon and select "Run as Administrator".
Once you open Visual Studio with Full admin rights, you will be able access the page without any issues.
I have had this error and it seems to be a generic error. As there are several answers to this issue, I am going to add mine. Republishing the website on the remote server seems to fix it for me.
I am in charge of a desktop WPF application, using a few web services (via Service References of the project).
Due to a Cannot execute a program. The command being executed was \"C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\csc.exe\" /noconfig /fullpaths #"C:\Documents and Settings\admin\Ustawienia lokalne\Temp\btucqeci.cmdline" error on a client's machine (which I understand is caused by csc trying to compile objects for the webservice request on the fly, and failing due to insufficient permissions), I hoped I could use a solution that I came across somewhere and enable the Generate serialization assembly option in the Build / Properties tab of my project.
It won't build, though - I keep on getting a compile error Could not find file 'E:\xxxx\xxxx\obj\Debug\xxxx.XmlSerializers.dll. Well I know it's not there, creating this DLL is precisely what I'm trying to achieve.
All the code for communicating with web-services is auto-generated and I haven't modified it at all.
I tried using sgen to achieve the same result "manually", but with no luck: I'm getting Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Could you point me in right direction? If additional information is needed, I will supply it. It's the first time I ran into this type of issue, so I'm a bit in the dark.
By the way, I have a (remote) access to the client's computer, but I failed to resolve the problem by resetting permissions. They run the program on an admin account and permissions do not seem to restricted in any way (based on what I googled up, including this question, I suspected the infamous IIS lockdown effect).
Recently we migrated our development environment from VS2008 to VS2010 (Ultimate).
For one solution (for now all C#, .NET Framework 3.5 and ASP.NET 2.0) which contains 6 projects VS auto-upgraded it without any problems.
The solution projects are:
ASP.NET website
VS2010 Web Deployment project for above site
Web Services Application
VS2010 Web Deployment project for above WSA
A class library.
Another class library.
However, when we build we have 1 error:
Could not load file or assembly 'ClassLibrary1BLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An API call exited abnormally. (Exception from HRESULT: 0x800300FA (STG_E_ABNORMALAPIEXIT))
After research I finally tracked this to one entry in the ASP.NET website config:
If I build with this line the problem occurs:
<identity impersonate="true" userName="DOMAIN\user" password="password"/>
However, if I comment out and build with the following line (without the supplied credentials) the solution builds fine AND then amend the web.config back to the above (with the credentials) the site runs fine - the credentials only cause a problem for the build.
<identity impersonate="true"/>
Now here is the strangest issue - the Web Services Application builds fine with the supplied credentials - the build error ONLY occurs for the ASP.NET website. This all holds true whether the projects are built individually or the solution rebuilt.
Any pointers how I can successfully build with the supplied credentials will be greatly appreciated.
Check the permissions of the impersonation user.
After just setting the flag to false, <identity impersonate="false"/>, it also came to life for me.
However, once setting it back to true, it built fine, but when I loaded the site, I got:
The current identity (XN-DTDEV\Fusion)
does not have write access to
'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary
ASP.NET Files'.
Now this machine is on a domain, and that user is local, which should have administrative privileges. When I checked back, it didn't. It looks like there is a policy re-setting the local administrators each reboot.
I realize there's already an accepted answer, but for anyone else coming to this page via a search on the error code....
Review the permissions of the user that you're trying to impersonate.
In my situation, I was only getting the error on my development machine, rather then on our staging or deployment servers. (For a while I got around this by removing the 'identity' node from config in my dev environment and just adding the line in post-build so it wasn't a problem anyone other than me..
In my environment we have a specific user that all our web apps impersonate when running. I had created the user account, but hadn't explicitly set its account permissions. When I added the user as an Adminstrator on my dev machine, this problem went away completely. (Not ideal, I know, but it "works for me", and has minimal harm since that user account is locked down on our 'real' servers anyways..)
after changing permissions on "Temporary ASP.NET Files" you need to delete its contents and allow the new files to inherit the new security permissions
If any of the solutions mentioned before didn't work, and you're using impersonation.
The answer is to give permission for the user that you're impersonating access to the following folders :
C:\Windows\Microsoft.NET\Framework[v4.0.30319 or the version that you're using]\Temporary ASP.NET Files
Your site directory.
also you might need to create folder as the following :
C:\Windows\Microsoft.NET\Framework\[v4.0.30319 or the version that you're using]\Temporary ASP.NET Files\[Application-Name-Goes-Here]
But try the previous first, it worked for me.
Those two changes for granting the impersonated user permission to be able to save the temp data, and pull the dll files, and any needed files from the directories
Thanks for the reply mattdwen - unfortunately your suggestion never worked (the 'Temporary ASP.NET Files' folder permissions were correct) but did provide the hint that lead to me (HACK) resolving the problem. After reading your answer I tried the following which led me in a different direction:
(1) I successfully rebuilt the solution 3 times using <impersonate="true"/>, <identity impersonate="false"/> and <identity impersonate="true" userName="DOMAIN\different-user" password="password"/> (here "different-user" is a local admin).
(2) I then amended the web.config back to the original <identity impersonate="true" userName="DOMAIN\user" password="password"/> and ONLY rebuilt the ASP.NET website project - success.
This has led me to conclude (strongly hinted at by the original error message) that VS when rebuilding the solution is unable (for as yet unknown reason) to build one of the Class Libraries or its dependencies with <identity impersonate="true" userName="DOMAIN\user" password="password"/> in the ASP.NET website project.
The Class Library in question has a number of references to 3rd party components, Office interops, etc. which for now would be too time consuming to attempt to eliminate one by one and discover the real underlying reason.
Therefore, I have temporarily implemented the hack (cringe) to add the original user to local admins.