3 messaggi dal 03 febbraio 2014
Buonasera,
vorrei poter utilizzare la libreria in oggetto per poter manipolare le URL. In locale funziona tutto, ma quando sposto l'applicazione sul provider mi ritorna l'errore 404. Abilitando gli Error Detail vedo che colui che mi ritorna il 404 e' il modulo StaticFile quindi non viene proprio caricato il modulo di UrlRewrite. Il file global.asax e' così fatto:
--------------global.asax--------------

void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(System.Web.Routing.RouteTable.Routes);
}

void RegisterRoutes(System.Web.Routing.RouteCollection routes)
{
routes.Add("dettaglioImmagine", new
System.Web.Routing.Route("Immagini/{titolo}-{id}/",
new RouteHandler("~/DettaglioImmagine.aspx")));
}

ed ho definito una classe RouteHandler, come

public class RouteHandler : IRouteHandler
{
private IHttpHandler _httpHandler;

public RouteHandler(string virtualPath)
{
_virtualPath = virtualPath;
}

public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
foreach (var paramUrl in requestContext.RouteData.Values)
requestContext.HttpContext.Items[paramUrl.Key] =
paramUrl.Value;

_httpHandler =
(IHttpHandler)BuildManager.CreateInstanceFromVirtualPath(_virtualPath,
typeof(Page));

return _httpHandler;
}

string _virtualPath;
}
---------------------fine---------------------------

Richiamando quindi l'url "http://www.miodominio.it/Immagini/test-100/?id=100" dovrebbe visualizzare l'url:
http://www.miodominio.it/DettaglioImmagine.aspx?id=100
Invece purtroppo mi viene ritornato un errore 404 sul file "test-100".
Sotto riporto il web.config:
--------------web.config-----------------
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
<section name="routingService" type="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</configSections>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
<providerOption name="CompilerVersion" value="v3.5" />
<providerOption name="WarnAsError" value="false" />
</compiler>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
<providerOption name="CompilerVersion" value="v3.5" />
<providerOption name="OptionInfer" value="true" />
<providerOption name="WarnAsError" value="false" />
</compiler>
</compilers>
</system.codedom>
<system.web>
<pages>
<namespaces>
<clear />
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Generic" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</controls>
</pages>
<compilation debug="false" numRecompilesBeforeAppRestart="1000" optimizeCompilations="true">
<assemblies>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="Default.aspx" defaultUrl="AreaRiservata/Default.aspx" timeout="480" />
</authentication>
<customErrors defaultRedirect="ErroreGenerico.aspx" mode="On">
<error statusCode="404" redirect="Errore404.aspx" />
</customErrors>
<httpHandlers>
<add verb="*" path="ofc_handler.aspx" type="OpenFlashChart.WebHandler.ofcHandler, OpenFlashChart" />
<remove verb="*" path="*.asmx" />
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpHandlers>

<httpModules>
<add name="RoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<remove name="ScriptModule" />
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated" />
<remove name="ScriptHandlerFactory" />
<remove name="ScriptHandlerFactoryAppServices" />
<remove name="ScriptResource" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
<httpErrors errorMode="Detailed" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

-------------------fine-----------------

Grazie a tutti.
11.886 messaggi dal 09 febbraio 2002
Contributi
Ciao,
fornisci qualche dettaglio in più sul webserver del provider: per caso si tratta di IIS6 o comunque il tuo sito appartiene ad un application pool che gira in modalità classica?

lorenzo.manetti ha scritto:

"Immagini/{titolo}-{id}/"

Dato che questa route si lega ad un URL senza estensioni (cioè non prevede .aspx o .ashx finale), è possibile che IIS non dia in pasto la richiesta al runtime di ASP.NET, ma cerchi lui stesso un file fisico sul disco. Ovviamente non lo trova, e tu ricevi un 404.

Questo è il problema degli "extensionless urls". Trovi vari articoli sul web, soprattutto in relazione ad IIS6.

Se il problema fosse effettivamente quello, ecco una soluzione non bella ma che non richiede interventi dalla console di IIS.
http://www.codeproject.com/Articles/44475/IIS-vs-ASP-NET-URL-Rewriting

Puoi sempre chiedere la collaborazione del tuo provider per risolvere il problema diversamente (ad esempio puoi farti spostare su un server IIS7 in modalità integrata).

ciao,
Moreno.
Modificato da BrightSoul il 15 aprile 2014 23.36 -

Enjoy learning and just keep making
3 messaggi dal 03 febbraio 2014
Ciao,
il provider mi ha fornito i seguenti dettagli:
OS: Windows Server 2012 R2
Web Server: IIS 8.5
Proxy Server: Application Request Routing 3
Application Pool Identity: Active Directory Users con MODIFY sul proprio spazio
Application Pool: 2.0 - Integrated

Spero ti possa servire.
Grazie
l
11.886 messaggi dal 09 febbraio 2002
Contributi
ciao Lorenzo,

lorenzo.manetti ha scritto:

Application Pool: 2.0 - Integrated

Probabilmente dipende dalla versione 2.0 del framework impostata su questo application pool. Se fosse la 4.0, l'UrlRoutingModule supporterebbe anche gli extensionless urls di cui ti parlavo nel post precedente.

Prima di fare questo cambiamento, però, prova una delle soluzioni elencate qui:
http://svenaelterman.wordpress.com/2011/01/31/using-asp-net-4-0-extension-less-routing-on-iis-7-5/

Nota che la prima soluzione, quella che usa il runAllManagedModulesForAllRequests="true", è la meno consigliata perché poi tutti i moduli andranno in esecuzione per tutte le richieste, anche quelle a file statici tipo jpg, css, js, eccetera.

ciao,
Moreno

Enjoy learning and just keep making

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.