Showing posts with label provided. Show all posts
Showing posts with label provided. Show all posts

Saturday, March 24, 2012

This type of page is not served.

I am beginning to create my first .net website and am running into a problem. Google provided little help. I tried to access an .asp file within one of my subfolders and am receiving the following error:


This type of page is not served.


Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.asp' may be incorrect. Please review the URL below and make sure that it is spelled correctly.

Is it possible to change the web.config or machine.config file to allow access to an .asp page? I'm new to .Net 2.0.

Thanks!

Hi,

do you use windows server 2003 in combination with IIS6? If so you need to know that IIS6, by default, has the settings set to off for serving ASP.NET or classic ASP pages.

Besides that, ASP.NET webforms need to have the extension .aspx, not .asp. This is needed to have IIS use the correct ISAPI filters.

Grz, Kris.


Yes, I'm on a win2003 server with IIS 6. What I'm basically trying to accomplish is create a 2.0 login system to replace our current system. We currently have a lot of sites written in classic asp and a few newer sites written in .NET 2.0. So what I have done is set up a test and everything works well, until I try to access an .asp page inside of one of our sites. I know that webforms need the .aspx extension, but am unsure of how to configure ISAPI or httphandlers to allow the execution of .asp pages. A general diagram of our system is below:

Our_Portal -- main folder, has 2.0 login features with links to the following subfolders/sites

Site_A -- .NET 2.0 site

Site_B -- classic ASP

Site_C -- classic ASP

When I try to access sites B and C, I get the "cannot serve pages" error. Is this more clear?

Tuesday, March 13, 2012

Thread Safety?

The following code hasbeen provided to me by a partner company for use in our asp.netapplication. Here is the class that I am questioning:

public class CurrentPageStyle
{
/// <summary>
/// The PageStyleRow for the current request.
/// </summary>
private static PageStylesDefinition.PageStyleRow currentpagestylerow;

/// <param name="ctxt">This gets the current pagestyle</param>
public CurrentPageStyle(HttpContext ctxt)
{
string keyword = ctxt.Request.QueryString["DView"];
if (keyword != null)
{
currentpagestylerow = TKConfiguration.Page_Styles_Definition.FindAll(keyword);
}
else
{
PageStylesDefinition.PageStylesRow toppsr = TKConfiguration.Page_Styles_Definition.GetFirst();
currentpagestylerow = TKConfiguration.Page_Styles_Definition.FindAll(toppsr.DefaultKeyword);
}
}

/// <summary>
/// This initializes the static member
/// </summary>
static CurrentPageStyle()
{
currentpagestylerow = null;
}

/// <summary>
/// Access to the current page style row for the request.
/// </summary>
public static PageStylesDefinition.PageStyleRow CurrentPageStyleRow
{
get
{
return currentpagestylerow;
}
set
{
currentpagestylerow = value;
}
}

Here is the usage from the global.asax file:

protected void Application_AcquireRequestState(object sender, EventArgs e)
{
CurrentPageStyle.CurrentPageStyleRow = null;
string[] pagestyle = Request.QueryString.GetValues('DView');
if (pagestyle != null)
{
if (pagestyle.Length != 0)
{
PageStylesDefinition.PageStyleRow psr = TKConfiguration.Page_Styles_Definition.FindAll(pagestyle[0]);
CurrentPageStyle.CurrentPageStyleRow = psr;
}
}

}

Myconcern is that the Application_AcquireRequestState event handler iscalled for every web request and it is setting a staticCurrentPageStyleRow which is then used later in the application. Myunderstanding is that there should only be one staticCurrentPageStyleRow per application and there can be web requests onmultiple threads so all of the threads will be sharing the sameCurrentPageStyleRow. Since there can be a differentCurrentPageStyleRow for each request, I think this is not thread safeand user 1 could end up getting user 2's CurrentPageStyleRow. I wantto make sure I am correct about this before reporting the issue to thepartner company. Am I right or am I off base?

Thanks,
Eric

In my modest opinion you should move that to an HttpModule to capture the request, and yes do not use an static class member! Why can't be an instance like the class?
Nice finding Eric! However some more people here may want to comment! Don't take my word for it

Al,

I am in the process of moving this to an HttpModule. As I said, the code was supplied by a partner company. I am in the process of adapting it to meet our needs. That was when I ran across this bit of code that does not appear to be thread safe. I am the only experienced .net developer on staff here, so I wanted someone else review the code and confirm my concerns before I reported it as a bug.

Thanks,
Eric