|
Subject:
|
Mixing Scripting Languages
|
|
Posted By:
|
digriz60
|
Post Date:
|
10/24/2003 1:03:21 PM
|
I'm developing an intranet site using Dreamweaver MX in a mixed ASP/ASP.NET environment (don't ask me why, probably becuase I want to learn .net) Dreamweaver MX doesn't have a 'restrict access to page' server behavior for .NET, so I am trying to use the VBScript code to perform the same function. First, is it possible to use old school VBScript in a .NET page? Second, this code:
dim MM_authorizedUsers, MM_authFailedURL, MM_grantAccess, MM_qsChar as string dim MM_referrer MM_authorizedUsers=""
returns an error that MM_authorizedUsers must be declared. I assume that will happen with all the variables (uh, yea, it's Dreamweaver generated code, I'm doing this on the fly)
Thanks,
Steve
|
|
Reply By:
|
Imar
|
Reply Date:
|
10/24/2003 1:34:38 PM
|
Hi there,
This is going to be complicated. It is possible to convert the Dreamweaver authentication code to ASP.NET. You'll need to do some strong typing (like: Dim MM_authorizedUsers As String = ""), enable sessions on your server and it may more or less work.
However, IMO, it's not going to be pretty. You can't really share Session state between the two technologies. Since the DW code uses Session for authentication purposes, you'll need to use ASP Sessions and ASP.NET Sessions to store the authentication information. This will most likely require your user to log on twice: once for each technology.
If they do have to logon twice, a) your users are not going to be happy and b) you might as well user ASP.NET authentication. ASP.NET authentication is relatively easy to set up and use, and pretty flexible.
I had the same issue in a corporate Intranet I designed and build for a customer. It was along running project, and while we were building it, ASP.NET came around which offered a lot of stuff we needed so we ended up with a dual-technology project.
If I had to do it all over again, I would port the old ASP code to ASP.NET and just use that for the entire site.
That said, it is possible to do what you want.
Here're the basic steps you need to perform:
1. Convert the ASP code to ASP.NET and make sure it works
2. In your old Login page, find a way to send data to the ASPX session object. You could for example use a self-submitting form that sends the username and roles from the ASP to the ASPX page. In the ASPX page, you'll need to save the required info like username and roles / (Access Levels to be exact) in the ASP.NET Session state. Alternatively, you can store the logon information in an encrypted cookie, and decrypt it again in the ASPX page (that's how we did it).
3. Include a User Control on each protected page that does the validation. Check the Session variables (like the Dreamweaver code does) and redirect away when the user has not been authenticated properly.
If you have the possibility, convert the entire ASP project to .NET (I heard there is a converter available from Microsoft, but I don't really trust / believe in this kind of things). On a single platform, things will be much easier down the road; you'll find that you'll often have to invent the wheel twice for each new feature you're going to add to your site.
Good luck, and if you have any specific conversion questions (or other questions), post them here.
Cheers,
Imar
--------------------------------------- Imar Spaanjaars Everyone is unique, except for me.
|
|
Reply By:
|
digriz60
|
Reply Date:
|
10/24/2003 6:12:18 PM
|
Imar,
Thank you for your input, it was very helpful. I am not committed to staying with ASP, in fact, I would prefer everything to be in .NET. Since I am a newbie, I am (early on) bound to using Dreamweavers pre-written server behaviors. Since a page restriction/user logon existed for ASP but not ASP.NET, I used it thinking I could rework the code later. If it is easier to build a page authentication in .NET, and use the session variable for all my aspx pages, I'll do that...I'm not married to ASP at all. My next question would be, if you or someone could direct me to a site that would help build that authentication out.
Thanks again,
Steve
|
|
Reply By:
|
Imar
|
Reply Date:
|
10/26/2003 12:52:18 PM
|
Hi Steve,
If you search the Web for "forms authentication" and ASP.NET you'll find plenty of examples. For example:
http://www.4guysfromrolla.com/webtech/110701-1.shtml
There are lots of other sites, tutorials etc. available.
Cheers,
Imar
--------------------------------------- Imar Spaanjaars Everyone is unique, except for me.
|
|
Reply By:
|
digriz60
|
Reply Date:
|
10/27/2003 1:05:44 PM
|
Thank you, that is exactly the kind of article I was looking for.
|