Application Startup

W

weeerob

Is there anyway to stop the application starting during the
Application_Start event in the Global.asax.cs file? I want to check a
license key at this point and not let the application start if it's
invalid. I've tried throwing an exception but that doesn't seem to
have any affect.

Thanks,



Rob.
 
G

Guest

That would only intercept the first user on the first visit.

You could go further with that and also incorporate logic into the
session_onstart that checks to see if an application variable was set and
redirect there also. However, if you are looking for a registration key or
something, does that mean that the files are hosted on the client's server?
If so, how are you blocking them from just editing the global.asa and
removing the check?

Thanks,
Ian Suttle
http://www.IanSuttle.com
 
J

Jeff Dillon

Have Session_OnStart check an Application flag, and take appropriate action

Jeff
 
R

Rick Strahl [MVP]

Hi Rob,

Application_Start might not be the best choice since it will only fire once
when the app starts. I don't think there's a way of making the app not
load - throwing an exception there will likely have some unexpected results.

A better approach might be to use Application_BeginRequest or hooking up
something inside of a custom page class (avoids somebody messing with
Global.asax), or hooking up a custom HttpModule dynamically at runtime (or
chaining Global.BeginRequest).

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
http://www.west-wind.com/wwThreads/
 
W

weeerob

Rick Strahl said:
Hi Rob,

Application_Start might not be the best choice since it will only fire once
when the app starts. I don't think there's a way of making the app not
load - throwing an exception there will likely have some unexpected results.

A better approach might be to use Application_BeginRequest or hooking up
something inside of a custom page class (avoids somebody messing with
Global.asax), or hooking up a custom HttpModule dynamically at runtime (or
chaining Global.BeginRequest).

+++ Rick ---

I figured if I couldn't stop the application in the application load
then I'd have to use Application_BeginRequest. Now can I throw a 500
error in this or can I only do redirects?

Thanks,


Rob.
 
J

Jeff Dillon

Try my suggestion. I have it working here.

Jeff
"Rick Strahl [MVP]" <[email protected]> wrote in message

I figured if I couldn't stop the application in the application load
then I'd have to use Application_BeginRequest. Now can I throw a 500
error in this or can I only do redirects?

Thanks,


Rob.
 
J

Jeff Dillon

I see you've considered session solutions.

Perhaps in Application_Start you could actually change the IIS user context
to an invalid account? The application could not start the next time with
an invalid service account

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top