-1

I uploaded my asp.net application through FTP from visual studio, after deploying it is throwing runtime(Parse Error).

I have seen several posts and tried many alternatives but none of them is working:

After uploading, the error was:

Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to 
service this request. Please review the following specific parse error 
details 
and modify your source file appropriately. 

Parser Error Message: Could not load type 'SimpleEchoBot.WebApiApplication'.

Source Error: 


Line 1:  <%@ Application CodeBehind="Global.asax.cs" 
Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>

Source File: /global.asax    Line: 1 

As mentioned in this post: Parser Error Message: Could not load type 'webmarketing', I changed CodeBehind to CodeFile but a new error has been raised stating that asax.cs does not exist!

Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to 
service this request. Please review the following specific parse error 
details and modify your source file appropriately. 

Parser Error Message: The file '/Global.asax.cs' does not exist.

Source Error: 


Line 1:  <%@ Application CodeFile="Global.asax.cs" 
Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>

Source File: /global.asax    Line: 1 

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET 
Version:4.7.3282.0

At the time my plesk file manager looked like this:

https://i.stack.imgur.com/BhNGv.jpg

And then I uploaded Global.asax.cs file and then this error showed up:

ERROR

As shown in this post: Parser Error: Server Error in '/' Application I changed Global.asax.cs namespace such that it is equal to the inherits path in asax!

Modified namespace code in asax.cs:

https://i.stack.imgur.com/8VPFs.jpg

code in asax:

<%@ Application CodeBehind="Global.asax.cs" Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>

but still, the above "This program is blocked by group policy" error is getting raised!

And I deployed the same application to Azure, same parse error, mentioned at the top is showing up!

Server Error in '/' Application. Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'SimpleEchoBot.WebApiApplication'.

Source Error:

Line 1: <%@ Application CodeBehind="Global.asax.cs" > Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>

Source File: /global.asax Line: 1

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3163.0

Edit: As requested by jessehouwing, here are the Bin folder Screenshots:

enter image description here enter image description here enter image description here enter image description here enter image description here

As @jeesehouwing comment mentioned, I tried to precompile the website and upload, but while precompiling I received few errors:

System.AggregateException: One or more errors occurred. ---> 
System.Exception: Publish failed due to build errors. Check the error list 
for more details.
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean 
 includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, 
CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish. 
<>c__DisplayClass40_0.<PublishAsync>b__2()
   at System.Threading.Tasks.Task`1.InnerInvoke()
    at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task 
task) atSystem.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)atMicrosoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__88.MoveNext()
 ---> (Inner Exception #0) System.Exception: Publish failed due to build errors. 
 Check the error list for more details.<---
Bobtheblobber
  • 91
  • 1
  • 4
  • 10

1 Answers1

1

Looks like you can only upload a pre-compiled website and can't include the Roslyn compiler in your deployment, as it's being blocked by the host. You can use Publish Profile in Visual Studio to configure pre-compilation (and I suspect you'll need to pick the "non-updatable" option).

See also:

More info

It looks like your web host has whitelisted which executables are allowed to run. This is a hardening practice to make an environment more secure. The most recent versions of ASP.NET include the C# compiler as part of the deployment to compile the MVC views and other elements on the fly. To do so your application ships the csc.exe compiler executable with your web application. csc.exe hasn't been whitelisted by the provider and that is blocking the dynamic recompilation of the Global.asax.cs.

Either target an older version of ASP.NET (which doesn't ship the roslyn compiler framework) or precompile the website so it no longer relies on the roslyn compiler to be present.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • @jeesehouwing If this is the case, then it should at least work in Azure! But it is responding the same way! – Bobtheblobber Jan 06 '19 at 13:56
  • In Azure it looks like you didn't deploy the code behind file and it looks like you didn't deploy all the dependent assemblies from the bin folder. Try adding the global.asax.cs to the Azure deployment to see if the error changes. – jessehouwing Jan 06 '19 at 14:20
  • Check the contents of the bin folder to see if there is an assembly containing `SimpleEchoBot.WebApiApplication` – jessehouwing Jan 06 '19 at 14:23
  • I uploaded code behind(gloabal.asax.cs) file to Azure., but still the same error `Parser Error Message: The file '/Global.asax.cs' does not exist.` I don't see any "SimpleEchoBot.WebApiApplication" in bin folder – Bobtheblobber Jan 07 '19 at 02:25
  • @jeesehouwing can you please look into my updated post! Thankyou – Bobtheblobber Jan 09 '19 at 01:34