El sitio asp.net no funciona desde la página predeterminada

I have a .net site set up that runs fine as long as you specify the full filename including .aspx extension on the page. As you try and run a default page without the specifiying default.aspx then a postback will not fire.

p.ej

http://www.site.com/ (postback does not work)

http://www.site.com/default.aspx (postback works)

http://www.site.com/directory (postback does not work)

http://www.site.com/directory/default.aspx (postback works)

I've never had this problem before on a .net website so struggling to understand what the problem is. I've checked most basic things, i.e. ensuring default.aspx is a default page etc. checking my web.config file against a site that is working properly etc.

I still don't understand why this behaviour is occurring. Any ideas?

preguntado el 12 de junio de 12 a las 17:06

Please show your form. Did you set the action ¿atributo? -

Is the site running on IIS or Visual Studio integrqted web server? -

A similar issue is described here: stackoverflow.com/questions/7228344/…. There are also some solution suggestions described. Take a look at it :). -

2 Respuestas

Lucas, thanks for sharing that answer.

Indeed the form action tag was empty in cases where the default.aspx had not been explicitly provided in the URL.

Adding the following code to global.asax has solved the problem:

void Application_BeginRequest(object sender, EventArgs e)
{
    var app = (HttpApplication)sender;
    if (app.Context.Request.Url.LocalPath.EndsWith("/"))
    {
    app.Context.RewritePath(
             string.Concat(app.Context.Request.Url.LocalPath, "default.aspx"));
    }
}

Respondido el 12 de junio de 12 a las 17:06

I'm glad You've found a satisfactory solution :). - Lucas M

I had this problem with one site and changed the Application Pool type to Classic. This fixed the problem.

Respondido 25 ago 20, 16:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.