Hosting MVC5, Identity 2 and OWIN on Godaddy - asp.net

I was wondering if anyone is hosting asp.net mvc5, identity2 and OWIN on Godaddy deluxe windows with plesk servers yet? I have followed all recommendations posted on the web but it is still not working. I have put same files on another server and the web application runs. I suspect this is a trust level. I have contacted support Godaddy and they are saying their server allows trust level 4 - which is confusing- is that medium trust or full trust? Are they being honest? I want to know if anyone has this type of hosting working before I cancel my hosting
Security Exception
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.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
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:
[SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Delegate.DelegateConstruct(Object target, IntPtr slot) +0
Owin.Loader.DefaultLoader..ctor(Func`3 next, Func`2 activator, IEnumerable`1 referencedAssemblies) +69
Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup() +65
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +28
System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +115
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +534
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

I know this is old, but I'm posting the solution so other people that comes to this question can be helped.
You just have to place the full trust element in your web.config, like this:
<system.web>
<trust level="Full" />
</system.web>

Related

hosting an application with the hosting provider (shared hosting)

I have an application that is working perfect on my local machine but it gives an error when uploaded in a hosting space. I called the technical support of my hosting provider and they are not technical enough to know what the problem is, they only tell me that they do no allows full trust level.
below is the error I get when visiting my URL:
Server Error in '/' Application.
Security Exception
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.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
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:
[SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Delegate.DelegateConstruct(Object target, IntPtr slot) +0
Owin.Loader.DefaultLoader..ctor(Func'3 next, Func'2 activator, IEnumerable'1 referencedAssemblies) +69
Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup() +65
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +28
System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +86
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +418
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34280
Screenshot of the error
Can anyone help me resolving this problem?
You're calling the Microsoft.Owin DLLs and those require full trust, they won't run under medium trust. If your host won't support full trust, you'll need to find an alternative to Microsoft.Owin that DOES run in medium trust, or switch hosting providers to one who DOES support full trust.
See this post Is trying to develop for Medium Trust a lost cause? for more details.

security exception in using routing in asp.net after doployment

i'm using routing in asp.net ,in local host every thing good , but after deployment , when browsing menu get below exception
Security Exception
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.Security.Permissions.
SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.
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:
[SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Web.Security.UrlAuthorizationModule.CheckUrlAccessForPrincipal(String virtualPath, IPrincipal user, String verb) +42
Microsoft.AspNet.FriendlyUrls.Abstractions.UrlAuthorizationModuleWrapper.CheckUrlAccessForPrincipal(String virtualPath, IPrincipal user, String verb) +14
Microsoft.AspNet.FriendlyUrls.FriendlyUrlRoute.GetWebObjectFactory(HttpContextBase httpContext, String modifiedVirtualPath) +159
Microsoft.AspNet.FriendlyUrls.FriendlyUrlRoute.Resolve(HttpContextBase httpContext, IList1 extensions, String virtualPathOverride, IFriendlyUrlRouteSupportFunctions supportFunctions) +220
Microsoft.AspNet.FriendlyUrls.FriendlyUrlRoute.Microsoft.AspNet.FriendlyUrls.Abstractions.IFriendlyUrlRouteSupportFunctions.Resolve(HttpContextBase httpContext, IList1 extensions, String virtualPathOverride) +16
Microsoft.AspNet.FriendlyUrls.FriendlyUrlRoute.GetRouteData(HttpContextBase httpContext, String pathOverride, IFriendlyUrlRouteSupportFunctions supportFunctions) +140
Microsoft.AspNet.FriendlyUrls.FriendlyUrlRoute.GetRouteData(HttpContextBase httpContext) +8
System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +233
System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +60
System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +82
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
any advice
This indicates, that your application is not running with Full trust on your IIS, or the trust level is not high enough.
Please follow the following checklist:
Open up IIS
Click on your website on the left panel
Double click on .NET Trust Level in the right panels.
Set the Trust Level to Full (internal)

asp.net mvc application not working after publish

i have a wired problem with my app.
as along as i run my app using visual studio, there is no problem but when i try to publish and run it using IIS i get the following error
[NullReferenceException: Object reference not set to an instance of an object.]
Achasoft.AchaCms.Web.RouteConfig.RegisterRoutes(RouteCollection routes) +813
Achasoft.AchaCms.Web.MvcApplication.Application_Start() +182
[HttpException (0x80004005): Object reference not set to an instance of an object.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9859725
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Object reference not set to an instance of an object.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
i read some articles about Application_Start in IIS 7 but shouldnt the default (asp.net mvc application template) routing work...
Please check the publish code that all the dll related to the MVC were published. Because by default MVC dll's was not copy to the local.
You should check these:
Server features, that supports asp.net site.
Too add all deployable dependencies.
If you have database, to check connection string
Check if your Hosting provider supports Specific version of MVC you are using or they even support MVC.

Weird ASP.NET (MVC) error: "Unable to load one or more of the requested types."

I'm getting weird error and I have no idea how to resolve it. I've got an ASP.NET MVC website which works fine but once I publish it to a server I get:
"Unable to load one or more of the
requested types. Retrieve the
LoaderExceptions property for more
information."
Stack Trace:
[ReflectionTypeLoadException: Unable
to load one or more of the requested
types. Retrieve the LoaderExceptions
property for more information.]
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
appContext, HttpContext context,
MethodInfo[] handlers) +206
System.Web.HttpApplication.InitSpecial(HttpApplicationState
state, MethodInfo[] handlers, IntPtr
appContext, HttpContext context) +188
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context) +295
System.Web.HttpApplicationFactory.GetPipelineApplicationInstance(IntPtr
appContext, HttpContext context) +56
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +231
[HttpException (0x80004005): Unable to
load one or more of the requested
types. Retrieve the LoaderExceptions
property for more information.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext
context) +8889839
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext
context) +85
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +333
I was trying to google some solution but so far have not found anything.
The website has quite a lot of references which is most probably the cause of this problem, however I have no idea how to identify the problematic assembly.
The website runs on a subdomain, root site is also ASP.NET MVC app.
After some investigation I was able to track the problem to (Fluent) NHibernate. It was not able to initialize itself due to security constraints on the server (read Medium Trust).
First I tried to update to latest version hoping it would work in medium trust environment. Then I tried to patch it to work and then I just simply gave up and contacted my hosting provider to raise the trust level for the app.

Subtext install gives error in Medium trust level

I am trying to install Subtext in a medium trust level environment (host: Crystaltech) and am getting the following error (see below). I was able to do the administration setup but when it tries to go to the blog for actual use, boom.
I know I could "upgrade" the environment to a full trust level but I want to understand why the error is happening and the ramifications of that moving to fUll trust before I do it.
To expand upon this question; what are the "Trust Levels"?
Security Exception
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.Security.Permissions.SecurityPermission,
mscorlib, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089'
failed.
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:
[SecurityException: Request for the
permission of type
'System.Security.Permissions.SecurityPermission,
mscorlib, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089'
failed.]
System.Web.Security.UrlAuthorizationModule.CheckUrlAccessForPrincipal(String
virtualPath, IPrincipal user, String
verb) +47
Subtext.Framework.UrlManager.UrlReWriteHandlerFactory.GetHandlerForUrl(String
url) +66
Subtext.Framework.UrlManager.UrlReWriteHandlerFactory.ProcessHandlerTypePage(HttpHandler
item, HttpContext context) +143
Subtext.Framework.UrlManager.UrlReWriteHandlerFactory.GetHandler(HttpContext
context, String requestType, String
url, String path) +340
System.Web.HttpApplication.MapHttpHandler(HttpContext
context, String requestType,
VirtualPath path, String
pathTranslated, Boolean useAppConfig)
+175 System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+128 System.Web.HttpApplication.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously)
+161
I don't think there is another way to get around the error other than moving to full trust or removing the call to CheckUrlAccessForPrincipal() and recompiling.
But by the looks of things, this particular issue has already been corrected in the subtext SVN (revision 3290). They have also added a new build task for subtext 2.0.1 which should include the fix. I guess that will be released when it's ready.
Trust levels are really just pointers to some security.config files. The dafault trust levels are defined in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config, "Medium" trust pointing to web_mediumtrust.config.
As for the exception, taking a look at System.Web.Security.UrlAuthorizationModule.CheckUrlAccessForPrincipal() with reflector reveals that the method is attributed with [SecurityPermission(SecurityAction.Demand, Unrestricted=true)], meaning that it requires an unrestricted security permission, which it does not have running under medium trust.
More grist to add to the mill from csgero:
http://www.kowitz.net/archive/2008/08/15/upgrading-to-subtext-2.0-fail.aspx
There's a wee comment from Phil Haack, I guess he's busy with other stuff right now :)

Resources