Uaktualniam mój projekt do ASPNET5. Moja aplikacja to aplikacja internetowa AngularJS, która korzysta z routingu adresu URL HTML5 (HTML5 History API).ASP.NET 5 Historia HTML5
W moim poprzednim aplikacji użyłem URL Rewrite IIS moduł z kodem jak:
<system.webServer>
<rewrite>
<rules>
<rule name="MainRule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" matchType="Pattern" pattern="api/(.*)" negate="true" />
<add input="{REQUEST_URI}" matchType="Pattern" pattern="signalr/(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="Default.cshtml" />
</rule>
</rules>
</rewrite>
<system.webServer>
Zdaję sobie sprawę, mogłem tego portu, ale chcę, aby zminimalizować moje okna zależności. Z mojego czytania wynika, że powinienem móc użyć oprogramowania pośredniego ASP.NET 5, aby to osiągnąć.
Myślę, że kod wyglądałby tak, ale myślę, że jestem dość daleko.
app.UseFileServer(new FileServerOptions
{
EnableDefaultFiles = true,
EnableDirectoryBrowsing = true
});
app.Use(async (context, next) =>
{
if (context.Request.Path.HasValue && context.Request.Path.Value.Contains("api"))
{
await next();
}
else
{
var redirect = "http://" + context.Request.Host.Value;// + context.Request.Path.Value;
context.Response.Redirect(redirect);
}
});
Zasadniczo, jestem chcąc niczego trasie, która zawiera /api
lub /signalr
. Wszelkie sugestie na najlepszy sposób osiągnięcia tego w ASPNET5?
Tak, możesz to osiągnąć dzięki "middleware" –
Dbanie, aby pokazać, jak możesz to osiągnąć? – amcdnl
Na 'GitHub' jest dużo próbek' middleware'. Jeden napisałem: https://github.com/aguacongas/chatle/tree/dev/src/ChatLe.HttpUtility –