Ich habe ein Problem mit einem Punkt in url Umbraco MVC benutzerdefinierte Routen. /logo/images/image.jpg?width=100 gibt folgende Fehler:Umbraco MVC benutzerdefinierte Routen mit einem Punkt in der URL
[NullReferenceException: Object reference not set to an instance of an object.]
Umbraco.Web.Mvc.UmbracoVirtualNodeByIdRouteHandler.FindContent(RequestContext requestContext, UmbracoContext umbracoContext) +18
Umbraco.Web.Mvc.UmbracoVirtualNodeRouteHandler.GetHttpHandler(RequestContext requestContext) +48
System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +11987058
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +141
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +91
/logo/images/image.jpg/?width=100
Works, aber das ist keine gute Lösung für mich. Ich habe versucht, in webconfig diese Zugabe
<location path="logo">
<!-- This only applies it to the relevant path and keeps the protection in place for elsewhere -->
<system.web>
<httpHandlers>
<add path="/images/*" type="System.Web.Handlers.TransferRequestHandler" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" />
</httpHandlers>
</system.web>
<!-- Required for IIS 7.0+ -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="ApiURIs-ISAPI-Integrated-4.0" path="*" type="System.Web.Handlers.TransferRequestHandler" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
</location>
von https://average-joe.info/allow-dots-in-url-iis/ genommen aber es wird nicht funktionieren :(
Meine individuelle Route wie folgt aussieht:
mitprotected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
//custom route
RouteTable.Routes.MapUmbracoRoute(
"images",
"logo/{action}/{key}",
new
{
controller = "Image",
key = UrlParameter.Optional,
},
new ProductsRouteHandler(4884));
}
}
public class ProductsRouteHandler : UmbracoVirtualNodeByIdRouteHandler
{
public ProductsRouteHandler(int realNodeId) : base(realNodeId)
{
}
protected override IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext, IPublishedContent baseContent)
{
return base.FindContent(requestContext, umbracoContext, baseContent);
}
}
Ich bin umbraco vs.7.4.3
Ihre Beispiel-URL ist für eine .jpg-Dateierweiterung, Umbraco enthält eine Abhängigkeit von ImageProcessor, die die dynamische Größenanpassung von Bildern übernimmt und für Ihre Anforderungen geeignet ist? – Anth12
ja Ich benutze ImageProcessor bereits im Imagecontroller, um die Größe von Bildern zu ändern. Die Bilder befinden sich außerhalb des Webservers und ich möchte, dass die Größenänderung ähnlich wie ImageResize.NET funktioniert. Dieser Code funktioniert, außer für das Routing wird die Verwendung eines Punktes am Ende nicht zulassen. –