简体   繁体   English

我在 .net6.0 中创建了 class 库并添加了我的 ViewComponent。我想在 asp.net 核心 mvc 应用程序中访问我的 viewcomponent 默认页面

[英]I created class library in .net6.0 and added my ViewComponent.I want to access my viewcomponent Default page in asp.net core mvc application

Hi I created my classlib and added my viewcomponents to that library and I added DLL file of my class library to asp.net mvc application I can able to use class and models but I don't know how to render cshtml page from library嗨,我创建了我的类库并将我的视图组件添加到该库,我将我的 class 库的 DLL 文件添加到 asp.net mvc 应用程序我可以使用 class 和模型,但我不知道如何从库中呈现 cshtml 页面

this is my library enter image description here这是我的图书馆在此处输入图片描述

this is how I configred it now enter image description here这就是我现在配置它的方式在这里输入图像描述

this is how I call enter image description here这就是我的调用方式enter image description here

Add the problem is enter image description here添加问题是在此处输入图像描述

I want to know how to configure cshtml page from classlib I use this as reference我想知道如何从 classlib 配置 cshtml 页面 我用它作为参考

https://www.davepaquette.com/archive/2016/07/16/loading-view-components-from-a-class-library-in-asp.net-core.aspx https://www.davepaquette.com/archive/2016/07/16/loading-view-components-from-a-class-library-in-asp.net-core.aspx

My Code https://github.com/Mohammedyasith/ViewComponent我的代码https://github.com/Mohammedyasith/ViewComponent

https://learn.microsoft.com/en-us/as.net/core/mvc/views/view-compilation?view=as.netcore-6.0&tabs=visual-studio#enable-runtime-compilation-conditionally https://learn.microsoft.com/en-us/as.net/core/mvc/views/view-compilation?view=as.netcore-6.0&tabs=visual-studio#enable-runtime-compilation-conditionally

Follow This Link to configer按照此链接进行配置

using Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation;
using Intelizign.Net.ViewComponents.NavBarViewComponent;
using Microsoft.Extensions.FileProviders;


var builder = WebApplication.CreateBuilder(args);

var env = builder.Environment;

builder.Services.AddRazorPages().AddRazorRuntimeCompilation();

var mvcBuilder = builder.Services.AddRazorPages();

if (builder.Environment.IsDevelopment())
{
    mvcBuilder.AddRazorRuntimeCompilation();
}

builder.Services.AddControllersWithViews();

builder.Services.AddApplicationInsightsTelemetry();

builder.Services.Configure<MvcRazorRuntimeCompilationOptions>(o =>
{   
    var libraryPath = Path.GetFullPath(
        Path.Combine(builder.Environment.ContentRootPath, "..", "vLib"));
    o.FileProviders.Add(new PhysicalFileProvider(libraryPath));             

});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.NET Core MVC在部分视图/ ViewComponent中提交表单 - ASP.NET Core MVC submit form in partial view / ViewComponent Asp.Net Core - 将responseCache与ViewComponent一起使用 - Asp.Net Core - Using responseCache with ViewComponent Asp.Net Core 2问题与ViewComponent和Redis - Asp.Net Core 2 issue with ViewComponent and Redis 如何从控制器(asp.net Core MVC)访问共享_Layout视图中的元素 - How can I access elements in shared _Layout view from my controller (asp.net core mvc) 我如何在我的 asp.net MVC 核心 web 应用程序中引用 static 文件 - How i can reference static files inside my asp.net MVC core web application 在我的 asp.net 核心 MVC web 应用程序中,我如何使验证码成为必填字段 - Inside my asp.net core MVC web application how i can make the recaptcha a required field 我正在使用 ClosedXML 库在我的 asp.net 核心 mvc 项目中导出 excel。我想按升序对名称列进行排序。如果有人对此有任何想法 - I am using ClosedXML library to export excel in my asp.net core mvc project.i want to sort name column by ascending.if anybody has any idea about that 我如何访问我的 asp.net 核心 MVC 中的注册过程 - How i can access the Registration process inside my asp.net core MVC 设置asp.net核心MVC应用程序的默认页面 - Setting default page for asp.net core MVC application 我如何告诉 MVC 中间件我的 class 是 ASP.NET Core 中的一个 Controller? - How do I tell the MVC middleware that my class is a Controller in ASP.NET Core?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM