-
Notifications
You must be signed in to change notification settings - Fork 10
AssetUrl call crashes with Server operation is not available in this context. #9
Copy link
Copy link
Open
Description
wiesniak
opened on Jul 1, 2019
Issue body actions
- The issue is related to Sitecore 9 application. App is hosted locally on IIS 10 with integrated v4.0 application pool. I did check with standard ASP.NET MVC app and it should work fine (details in 4.; similar deployment settings).
- Webpack configuration is done via sitecore's initialize pipeline. This is a substitute for Application_Start and works fine with all initializations that I have. Configuration code:
- Build succeeds, but when trying to enter website, application crashes with exception
- I did some digging and found out that applicationInstance used in registration has Server property with null assigned to _context. This propagates into HttpServerUtility.MapPath and crashes as this method requires _context field to exist. In standard ASP.NET MVC app this _context is filled at Application_Start.
- When I move the code from initialize pipeline's handler directly to _Default.cshtml then everything works fine, because at this point HttpContext.Current.ApplicationInstance.Server contains _context with proper object assigned.
- I found out a suggestion (here) to use System.Web.Hosting.HostingEnvironment.MapPath method instead of HttpServerUtility.MapPath, because it does not require HttpContext and under the hood HttpServerUtility.MapPath reaches to suggested method.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels