[英]Is there a way to use a .cshtml file as the popup in a chrome extension?
I want to be able to use the view functionality that a .cshtml would provide me. 我希望能够使用.cshtml为我提供的视图功能。 Is there anyway to make this happen?
反正有做到这一点? I already have one loaded but it outputs as plain text.
我已经加载了一个,但是输出为纯文本。 Is there some service or project that will render a .cshtml file?
是否有一些服务或项目将呈现.cshtml文件?
No. 没有。
cshtml
requires a specific server to render it properly, and that is not part of Chrome. cshtml
需要特定的服务器才能正确呈现它,而这不是Chrome的一部分。
I mean, technically you can host a page somewhere and embed it in the popup as an <iframe>
, but I doubt that's an acceptable solution. 我的意思是,从技术上讲,您可以在某个地方托管页面并将其作为
<iframe>
嵌入到弹出窗口中,但是我怀疑这是可以接受的解决方案。
You can achieve this by using Partial View. 您可以通过使用部分视图来实现。 Here below sample code for this.
在下面的示例代码中。
<div class="row">
<label>Id : </label>
@Html.DisplayFor(model => model.Id)
<label>Name: </label>
@Html.DisplayFor(model => model.Name)
</div>
then create one action in your controller like 然后在控制器中创建一个动作,例如
public PartialViewResult GetProfilePartial()
{
var model = new ProfileViewModel()
{
Id = 1,
Name = "Sample User";
};
return PartialView("PartialViewName", model);
}
You can import rendered html of this view by calling GetProfilePartial action by ajax call. 您可以通过ajax调用GetProfilePartial操作来导入此视图的呈现的html。 Hope this will help you.
希望这会帮助你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.