3

I have built a WCF application which has Global.asax file. I have added AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required) on top of service class and added into web.config as well. Global.asax Application_Start event fires when debugging the application but when it deployed in the IIS7 its not firing.

Any help or idea?

Thank you.

user2822319
  • 541
  • 1
  • 5
  • 8

1 Answers1

0

If you make a request to your app does the "Application_Start" fire then? I don't believe it will be started until the first request is made.

Application level events only need proper naming to work. Is your codebehind class being designated in your Global.asax file?

 <%@ Application Inherits="YourNamespace.YourApplicationClass" Language="C#" %>

(Or)

becuase project is compiled first and then you have add or modify or changed location of global.asax.cs.

Solution :- Just remove debug folder. Clean project and then rebuild whole project.

Edit

When using the response object from an aspx page, its codebehind class or a user control, the response object is directly available because all these derive from the page object.

When using the response object in your own class, the object is not available, but you can access it:

HttpContext.Current.Response. -> something

Take a look at here

Global ASAX - get the server name

Community
  • 1
  • 1
Vignesh Kumar A
  • 27,863
  • 13
  • 63
  • 115
  • Thank you. But the global.asax file is physically available on the server. – user2822319 Feb 09 '14 at 14:18
  • I'm sorry its firing. It throws an exception 'Response is not available in this context'. It has Request.GetResponse in the code. Why response not exists in global.asax? – user2822319 Feb 10 '14 at 03:27
  • I think you are using response object in your own class. This object will not be available there. Try using like this eg: HttpContext.Current.Response.Redirect("~/Account/Dashboard.aspx"); – Vignesh Kumar A Feb 10 '14 at 03:29
  • I'm not doing any redirection I'm just calling a web service and tring to obtain the response. But still Response is available in the debug mode. – user2822319 Feb 10 '14 at 03:33
  • You don't need to redirect.I just gave for example. in your case replace response with HttpContext.Current.Response – Vignesh Kumar A Feb 10 '14 at 03:38
  • I added new REST call instead of App start event. Thanks a lot for all your help – user2822319 Feb 10 '14 at 06:26