6

I'm just going through the Sitecore documentation for setting up a Visual Studio project.

One of the steps is to update the global.asax file in your solution:

In the Visual Solution folder, copy the global.asax file from the Website folder of the Sitecore installation, overwriting the global.asax Visual Studio added when you created the project.

I'm just wondering why this is necessary? If we delete the global.asax file - will it cause Intellisense issues with VS or something similar? We can use WebActivator to run code on start-up so we don't need to overwrite this file.

If the global.asax is required fr some reason, could we set it not to publish (e.g. set the Build Action) rather than copying it from Sitecore.

0

3 Answers 3

11

It's not required to be included or even included and then excluded from publish, it will not cause any issues with Intellisense or any other function of Visual Studio.

The only reason for including it would be if you need to include some custom code on startup, even then it would be preferable to add a processor to into the initialize pipeline and run your logic there.

If you do need to add custom logic that for some reason has to go in Global.asax the make sure you inherit from Sitecore.Web.Application as Mark Cassidy has pointed out.

1
  • One if the reasons why you could include the Global.asax file would be to setup the wiring for configuring the DI container for the Solr package - but as you say, even then I would also recommend doing this using a pipeline. Oct 25, 2016 at 16:31
6

A Sitecore solution application needs to inherit from Sitecore.Web.Application.

<%@Application Language='C#' Inherits="Sitecore.Web.Application" %>

Inside the application code; Sitecore manages session events (for xDB and so on).

I guess, theoretically, you could refactor this into something else or a different approach. I'm not sure what repercussions you risk in doing so, however.

To answer your question about publish; I normally don't include Global.asax in my solution/project - it therefore isn't a problem when publishing either. Sitecore recommends you develop outside your website root. So in short; if you leave it be, and do not include it in your project, it will not overwrite the default Sitecore one in your target folder.

0

If you don't intend to work with the global.asax file then I suggest to delete the one Visual Studio created with the solution. No need to include the one from Sitecore

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.