473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Protecting classic ASP pages with ASP.NET 2.0

I found a article on how to do this at:
http://www.oreillynet.com/windows/bl...resources.html

But could not get is working on my Windows XP Professional development
environment, that is confirmed by "To be clear, this does not work with
ASP.Net 2.0 on IIS5 " on
http://blogs.msdn.com/david.wang/arc...T_content.aspx

So I moved the application on a dev Win2003/iis6 environment - now I
get "The underlying connection was closed: The connection was closed
unexpectedly" exception.

Any ideas please?
This should be possible?

Thanks, gert

My web.config:
<httpModules>
<add name="gecHttpModule" type="myHttpModule.gecHttpModule"/>
</httpModules>
<httpHandlers>
<add path="*.asp" verb="GET,HEAD,POST"
type="System.Web.DefaultHttpHandler" validate="true"/>
</httpHandlers>

where gecHttpModule is my HttpModule that rewrite the url ONLY when a
certain key/value DONT occur in the querystring:
httpApp.Context.RewritePath(string.Format(@"~/FileViewerAsp.aspx?article={0}",
myPageNameRequested), false);

on FileViewerAsp.aspx:
private void displayArticle()
{
object o = Request.Params["article"];
if (o != null)
{
string pageName = o.ToString();

if (pageName.ToLower().EndsWith(".asp"))
{
pageName += @"?";
}

if (pageName.IndexOf(".asp") != -1)
{
if (!pageName.ToLower().EndsWith("?"))
pageName += @"&";

pageName += "ui2=true";
}

HttpWebRequest request;
StreamReader sr = null;
try
{
request = (HttpWebRequest)HttpWebRequest.Create(pageName);
request.Referer = "http://localhost";
request.PreAuthenticate = true;
request.AllowAutoRedirect = true;

request.ContentType = "text/html";
request.Timeout = 300000;

sr = new StreamReader(request.GetResponse().GetResponseStre am());
string rawHtml = sr.ReadToEnd();
// Use regex to extract title and body
Regex reHtml = new
Regex(@"<title\b[^>]*>(?<Title>.*)</title\b[^>]*>.*<body>(?<Body>.*)</body>",
RegexOptions.IgnoreCase | RegexOptions.Singleline);
MatchCollection mc = reHtml.Matches(rawHtml);

if (mc.Count == 0)
throw new ApplicationException("Regex could not found correct tags");

this.Title = mc[0].Groups["Title"].Value;
LabelArticle.Text = mc[0].Groups["Body"].Value;

}
catch (Exception ex)
{
LabelArticle.Text += "Article not unavailable - " + ex.Message + "
StackTrace = " + ex.StackTrace;
}
finally
{
if (sr != null)
sr.Close();
}
}

Aug 2 '06 #1
0 799

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: John | last post by:
Dear all, I've got a security question that is so difficult that "maybe" there will be no answer for it. It's regarding protecting asp code. I did write some asp code, that I sell to...
5
by: Velvet | last post by:
Can someone tell me to what process I need to attach to be able to step through my classic ASP code in VS.net 2003. I'm working on an XP box with IIS installed. I also have VS.net 2005 (The...
2
by: nullref | last post by:
I'm having trouble setting up my classic ASP site to correctly handle .NET web config file for migration I need to do. If the config file is at the same level as my other pages I get the...
4
by: KJS | last post by:
Help, I'm not sure what exactly is happening but I can say this, classic asp pages are not loading on my local dev box. They use to work! Since then I have installed .NET 1.1 Studio (that is...
6
by: John | last post by:
Hello. I believe I've read somewhere that classic .asp pages will still operate correctly with no problems with the .NET 1.1 framework installed on a Windows 2000 Server server. Does anyone know...
5
by: Kent.Gallinger | last post by:
I have a web application that contains asp.net and classic asp pages. I have a vb.net function that I would like to use in one of the classic asp pages. How can I do this? Can I do this? ...
12
by: Dr. Edmund M. Hayes | last post by:
I wrote a access program that works well enough that a handful of people would like to buy it from me. My problem is that if I sell it to someone there is no mechanism that I know of to protect...
11
by: mase | last post by:
I've built a new ASP.NET web app with the CSLA framework. The site runs fine with a small number of users, but once there is any traffic the CPU spikes at 100%. I went through and made many updates...
12
by: mcp6453 | last post by:
My small company has a web site that is developed in "Classic ASP", which is, I'm told, different from just "ASP". It is clear to me that we are not using ASP.NET. The site is hosted on a shared...
1
by: andwan0 | last post by:
I have a legacy classic ASP website with lots of classic AJAX (many ASP files specially made for processing AJAX requests). We are slowly migrating the website to ASP.NET 2.0 and developing under...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.