Self hosting web application using Hostable Web Core - c#

Am trying to host a web application (aspx web form) using hostable web core feature.
Using this when i tried to load the aspx page, am getting error
error details :
responce : 502
The connection to 'localhost' failed. Error: ConnectionRefused
(0x274d). System.Net.Sockets.SocketException No connection could be
made because the target machine actively refused it 127.0.0.1:8080
Then i changed the CodeBehind attribute to CodeFile , after that am getting this error :
Object reference not set to an instance of an object.
Description: 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.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
System.Web.HttpResponse.ApplyRedirectQueryStringIfRequired(String url)
+144 System.Web.HttpResponse.Redirect(String url, Boolean endResponse) +546
System.Web.Security.FormsAuthenticationModule.OnLeave(Object source,
EventArgs eventArgs) +1730
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+412 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +229
In the same application am having a test page in html format. When i tried to access that page, it's rendering properly.
Here am adding my configuration file also
AppHostAspNet.config

After some code changes and some configuration changes now it's working.
Here am attaching the working sample. Sample
In Program.cs change the code physical path
WebServer server = new WebServer( #"C:\project_path", port, siteId );

Related

Error in ASP.NET Core application when using Google authentication

My application is built in .Net core 6. I have google login page in my application to authenticate. I am able to login but after sometime it getting hanged. When I checked the error logs, I found the log
RequestPath: /signin-google
'.AspNetCore.Correlation.Tqs1QKvDfDtMzN1758B177fdEvPXBxm0_NuiFaB1ySc' cookie not found.
RequestPath: /signin-google
An unhandled exception has occurred while executing the request.
Exception:
System.Exception: An error was encountered while handling the remote login.
---> System.Exception: Correlation failed.
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.HandleRequestAsync()
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
I removed samesite rule from program.cs but still the error persist

How to fix the Server Error(parse Error) after deploying te asp.net site

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:
And then I uploaded Global.asax.cs file and then this error showed up:
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://imgur.com/59d4IJK.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:
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.<---
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:
https://stackoverflow.com/a/40225124/736079
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.

No service for type 'Microsoft.Framework.Runtime.ILibraryManager' has been registered

I'm currently doing a project on the new version of ASP.NET. I'm getting this really annoying error when I run a new empty ASP.NET project. There's nothing else in the project than the generated code... I tried changing the CLR's, but nothing helps.
I'm getting this error:
Server Error in '/' Application.
No service for type 'Microsoft.Framework.Runtime.ILibraryManager' has
been registered.
Description: 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.
Exception Details: System.InvalidOperationException: No service for
type 'Microsoft.Framework.Runtime.ILibraryManager' has been
registered.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: No service for type
'Microsoft.Framework.Runtime.ILibraryManager' has been registered.]
System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags
hostingFlags, PolicyLevel policyLevel, Exception
appDomainCreationException) +303
[HttpException (0x80004005): No service for type
'Microsoft.Framework.Runtime.ILibraryManager' has been registered.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9940016
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
+101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +261
---------------------------------------------------------------------- I'm running the 1.0.0beta5 clr x64 on windows 8.1.
Does someone know how to solve this error?
When I google for 'Microsoft.Framework.Runtime.ILibraryManager' I find several issues in github mentioning that error. It sounds like it happens when you have mismatched packages, ie if you still have some beta4 packages listed in project.json

unable to run react.net in 64-bit mode on iis

I have followed http://reactjs.net/getting-started/tutorial.html to get started with ReactJS.
The first step works fine running in IISExpress. However running the same example in "real" IIS does not work. I Get the following error:
Server Error in '/' Application.
Unable to resolve type: React.Web.IJsxHandler
Description: 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.
Exception Details: React.TinyIoC.TinyIoCResolutionException: Unable
to resolve type: React.Web.IJsxHandler
Source Error: An unhandled exception was generated during the
execution of the current web request. Information regarding the origin
and location of the exception can be identified using the exception
stack trace below.
Stack Trace: [TinyIoCResolutionException: Unable to resolve type: React.Web.IJsxHandler]
React.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration
registration, NamedParameterOverloads parameters, ResolveOptions
options) +1165 React.TinyIoC.TinyIoCContainer.Resolve() +163
React.Web.JsxHandlerFactory.ProcessRequest(HttpContext context) +52
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+913 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
If I set the "Enable 32-bit applications" setting to true in the application pool, the solution starts to work.
Based on this, I guess the problem is related to instantiating the 64-bit react dll (or v8 component).
I have tried installing the x64 run time components (both 2012 and 2013) to no avail.

singalR with windows 8

Has anyone gotten signalR to run on Windows 8 or Server 2012? When I browse to the signalr url I recieve the following error:
Protocol error: Unknown transport.
Description: 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.
Exception Details: System.InvalidOperationException: Protocol error: Unknown transport.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Protocol error: Unknown transport.]
SignalR.PersistentConnection.ProcessRequestAsync(HostContext context) +1052
SignalR.Hosting.AspNet.AspNetHandler.ProcessRequestAsync(HttpContextBase context) +746
SignalR.Hosting.AspNet.HttpTaskAsyncHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +97
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12551795
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
SignalR works fine on Windows 8 and Server 2012, your problem does not seem to be specific to the OS.

Categories

Resources