久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

.razor 文件中的 Blazor 基本標記和 @page 指令

Blazor base-tag and @page instruction in .razor files(.razor 文件中的 Blazor 基本標記和 @page 指令)
本文介紹了.razor 文件中的 Blazor 基本標記和 @page 指令的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我開始使用 Blazor 服務器端,但我沒有得到正確的路由.我不明白 _host.cshtml 中需要 base 標記.如果我仍然需要在每個 Blazor 組件中添加 base url,例如:我想要一個 /app/ 的基地址和 @page<值為 "/counter" 的示例 Counter 的/code> 指令不會編譯"為 "/app/counter".我必須將 @page 設置為 "/app/counter" 這很有意義,但這意味著 _host 中的 base 標記.cshtml 沒用...

我在這里做錯了什么?

解決方案

<base href='' > 是一個

I am getting started with Blazor server-side and I don't get the routing right. I don't understand the need for the base tag in _host.cshtml. If I still have to add the base url in every Blazor component, for example: I want to have a base address of /app/ and the @page directive for the example Counter with a value of "/counter" does not "compile" to "/app/counter". I have to set the @page to "/app/counter" which makes sense but that means that the base Tag in _host.cshtml is useless...

What am I getting wrong here?

解決方案

The <base href='' > is a client side technology that specifies the base URL for all relative URLs in current document. Many SPA frameworks , e.g. Angular, will use this element.

I have to set the @page to "/app/counter"

Actually, you don't have to and should never do that. One of the most important advantages when using <base> is that it allows us to create an app without letting the components know about the base url.

Assuming you've changed the base href from '/' to '/app/', and also changed the other relative urls:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>BlazorApp</title>
    <base href="/app/" />
    <link rel="stylesheet" href="/css/bootstrap/bootstrap.min.css" />
    <link href="/css/site.css" rel="stylesheet" />
</head>
<body>
    <app>
        @(await Html.RenderComponentAsync<App>(RenderMode.ServerPrerendered))
    </app>

    <script src="/_framework/blazor.server.js"></script>
</body>
</html>

Don't forget to prepend the default Blazor Hub url with a /app/ :

app.UseEndpoints(endpoints =>
{
    endpoints.MapBlazorHub("/app/_blazor");
    endpoints.MapFallbackToPage("/_Host");
});

That's all. There's no need to change the routes from @page "/counter" to @page "/app/counter" at all.

Demo

Here's a demo that we don't change the @page routes for components:

這篇關于.razor 文件中的 Blazor 基本標記和 @page 指令的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 天天操天天怕 | 久久久久午夜 | 精久久久 | 亚洲精品在线视频 | 91偷拍精品一区二区三区 | 日本一二区视频 | 亚洲v日韩v综合v精品v | 国产精品视频在线观看 | www国产成人免费观看视频,深夜成人网 | 国产91精品久久久久久久网曝门 | 伊人一区 | 国产精品永久久久久 | 国产伦精品一区二区三区照片91 | 综合一区 | 中文字幕91 | 自拍偷拍中文字幕 | 亚洲高清免费视频 | 日韩a | 久久久久国产一区二区三区不卡 | 99福利视频导航 | 婷婷福利视频导航 | 久久99精品国产 | 999久久久久久久久6666 | 亚洲一区在线日韩在线深爱 | 一区二区三区久久 | 欧美日韩中文字幕在线 | 精品一区二区三区在线观看国产 | 国产亚洲精品久久情网 | 国产精品久久久久久一区二区三区 | 久久伊人免费视频 | 国产精品久久久久久久久久久久 | 91精品国产91久久久 | 不卡的av一区| 中文字幕高清 | 午夜精品久久久久久不卡欧美一级 | 性欧美xxxx | 色综合美女 | 欧美区日韩区 | 欧美精品福利 | 国产精品久久av | 亚洲一区二区三区在线视频 |