惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Cisco Talos Blog
Cisco Talos Blog
C
Check Point Blog
博客园_首页
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
S
Security @ Cisco Blogs
L
LINUX DO - 最新话题
博客园 - 司徒正美
P
Privacy International News Feed
G
Google Developers Blog
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
K
Kaspersky official blog
I
InfoQ
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Webroot Blog
Webroot Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
D
Docker
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Microsoft Azure Blog
Microsoft Azure Blog
Spread Privacy
Spread Privacy
量子位
H
Hacker News: Front Page
Simon Willison's Weblog
Simon Willison's Weblog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
SecWiki News
SecWiki News
S
Security Affairs
Latest news
Latest news
人人都是产品经理
人人都是产品经理
C
CERT Recently Published Vulnerability Notes
S
Security Archives - TechRepublic
V
Visual Studio Blog
T
Troy Hunt's Blog
S
Secure Thoughts
F
Fortinet All Blogs
V
V2EX
The Register - Security
The Register - Security
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - known

基于Blazor实现的跟踪光伏智能运维平台 基于Blazor实现的电梯运行监测系统 基于Blazor实现的样品扫码比对管理系统 基于Blazor实现的简易进销存管理系统 InfluxDB2时序数据库查询教程 InfluxDB2时序数据库安装教程 基于Blazor实现的运输信息管理系统 React+Next.js+MaterialUI+Toolpad技术栈学习——安装 Blazor开发框架KnownPro-创建新项目 Blazor开发框架Known-V2.0.13 Blazor开发框架Known-V2.0.11 Blazor静态服务端呈现(静态SSR)身份认证 Blazor开发框架Known-V2.0.10 Blazor开发框架Known-V2.0.9 Blazor开发框架Known-V2.0.8 Blazor开发框架Known-V2.0.7 Blazor Web 应用如何实现Auto模式 Win11系统Docker部署Blazor程序 Known框架实战演练——进销存财务管理 Known框架实战演练——进销存业务单据 - known Known框架实战演练——进销存基础数据 - known
Blazor程序混合Razor页面
known · 2024-08-02 · via 博客园 - known

1. 修改Program

//添加Razor页面
builder.Services.AddRazorPages();
//使用路由,需在app.UseAntiforgery();之前添加
app.UseRouting();
//映射Razor页面
app.MapRazorPages();

2. 添加Razor页面

  • 新建Pages文件夹
  • Pages文件夹中添加_ViewImports.cshtml文件
@using Sample.Web
@namespace Sample.Web.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
  • Pages文件夹中添加Razor页面,命名Test,自动生成Test.cshtmlTest.cshtml.cs两个文件
  • Test.cshtml文件示例如下:
@page
@model TestModel

<h2>@Model.Id</h2>
  • Test.cshtml.cs文件示例如下:
namespace Sample.Web.Pages;

public class TestModel : Microsoft.AspNetCore.Mvc.RazorPages.PageModel
{
    public string Id { get; set; }

    //路由:域名/test?id=123242
    public async void OnGet(string id)
    {
        Id = id;
    }
}