asp to asp.net conversion

J

John

Hi

I have a pure asp app which I need to integrate into an asp.net app in terms
of the asp.net membership/roles/login that asp.net app uses. I understand
there is no way for a pure asp app to share session etc. with asp.net i.e.
it can't work with asp.net membership/login. In which case is there a way to
convert asp app into some sort of psuedo asp.net app to make it work with
asp.net membership?

Thanks

Regards
 
S

Scott M.

Well no, not really. You either have ASP.NET code or you don't. You *can*
have both running in one application and simply persist your data in a
database, rather than using sessions. Both Classic ASP and ASP.NET can
access databases.
 
B

Brennan Stehling

John,

Can you provide more detail on how you expect to use the membership and
roles features?

What you can do is mix classic ASP and ASP.NET pages for the same
website. From there you can provide an ASP.NET login screen and place
the ASP.NET 2.0 login control on it and configure web.config for how
the ASP.NET website will function, either Forms or Windows
authentication as well as what locations are protected.
From that point you could use Javascript to send requests from the
classic pages to the ASP.NET sites to get access to the features which
you want protected by the membership and roles features. Depending on
what you need to do this could be easy or very tricky.

One technique which I have used is to pull a URL with an AJAX request
for a full ASPX page which has all of the content with comment markers
placed around the results, such as...

<!-- RESULTS START -->
... results go here ...
<!-- RESULTS END -->

For the AJAX reponse, you can parse the responseText with the indexOf
function. Here is some code to do that...

var startMarker = "<!-- RESULTS START -->";
var endMarker = "<!-- RESULTS END -->";
var startIndex = t.responseText.indexOf(startMarker) +
startMarker.length;
var endIndex = t.responseText.indexOf(endMarker);
var contentBlock = document.getElementById('content');

if (startIndex != -1) {
var contentResults = t.responseText.substring(startIndex,
endIndex);
contentBlock.innerHTML = contentResults;
}

You can then place whatever content the ASP.NET page generated into you
classic ASP page. The AJAX request will provide the membership
information with the same cookies as a normal request, so the
authentication token use for the ASP.NET membership will be available.

In your case I would also check for a status block because a user may
not be authenticated or their session may have expired or somehow
become invalid.

<!-- STATUS START -->
OK
<!-- STATUS END -->

And check that the page was returned OK, or with access denied based on
the role.

Over time you can phase in more and more of the ASP.NET content and
reduce the classic ASP pages. Just be sure to create these content
bits as User Controls so it is easy to wrap them in different pages
based on their use. That will give you a great deal of flexibility.

Brennan Stehling
http://brennan.offwhite.net/blog/
 

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,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top