You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I once built a website that included URL rewriting. For example, /washing-machines/front-loaders/samsung/X5000 was rewritten to /product.aspx?prodId=100. I also implemented this in a sample site that uses the Componyx framework; however, because the view, controller, and server method are determined there via $bindary.addroute, the URL rewriting—which is triggered during startup—doesn't work correctly. I’ve included the function that handles the URL rewriting below.
public async Task Invoke(HttpContext context)
{
var urls = await GetUrls();
var requestedPath = context.Request.Path.Value;
var url = urls.FirstOrDefault(x => string.Equals(x.UrlRewrite, requestedPath, StringComparison.OrdinalIgnoreCase));
if (url != null && !string.IsNullOrWhiteSpace(url.UrlTarget))
{
if (url.Url301)
{
context.Response.Redirect(url.UrlTarget, true);
return;
}
else
context.Request.Path = url.UrlTarget;
}
await _next.Invoke(context);
}
The rewrite runs on the server, but in a Bindary app the client decides which view to show, based on the URL in the address bar. Since the browser still shows /washing-machines/front-loaders/samsung/X5000, Bindary looks for a route matching that path and finds none. You don’t need a rewrite here; make the pretty URL the route itself and let the server method look up the product.
Activity
edaanen commentedon Nov 9, 2026
The rewrite runs on the server, but in a Bindary app the client decides which view to show, based on the URL in the address bar. Since the browser still shows /washing-machines/front-loaders/samsung/X5000, Bindary looks for a route matching that path and finds none. You don’t need a rewrite here; make the pretty URL the route itself and let the server method look up the product.
Something like this:
$bindary.addRoute({ path: /^washing-machines\/(.+)$/, viewURL: '/views/product.aspx', controllerURL: '/scripts/product.js', dataRequest: { productPath: '$1' }, dataServerLoad: 'Shop.Product.Controller.Load' });