razor

relative path in stylesheets within asp.net mvc areas

泪湿孤枕 提交于 2021-01-27 05:04:59
问题 I have a project with the current structure My Project /Content /Controller /View /Model /Areas /Area1 /View /Controller /Model /Area2 /View /Controller /Model All of the area views are using a root shared _Layout view which is referencing a css file under the root content directory. The css file under the content folder is referencing images or other content with the same directory like below: .box-shadow { -webkit-box-shadow: 0px 5px 80px #505050; -moz-box-shadow: 0px 5px 80px #505050; box

How do I make Razor read UTF-8 files without BOM?

梦想的初衷 提交于 2021-01-27 01:12:00
问题 We have separated teams for front end and back end work. The front end is using a large diversity of editors to edit the CSHTML and most of them save UTF-8 without a byte order mark. The problem is, Razor expects a BOM to be present. If it's not present it will read the file using the current code page and we get encoding problems. How would I make Razor to accept the UTF-8 files without a BOM ? Apparently the only solution would be to implement an own VirtualPathProvider and thus also a

How do I make Razor read UTF-8 files without BOM?

若如初见. 提交于 2021-01-27 01:08:21
问题 We have separated teams for front end and back end work. The front end is using a large diversity of editors to edit the CSHTML and most of them save UTF-8 without a byte order mark. The problem is, Razor expects a BOM to be present. If it's not present it will read the file using the current code page and we get encoding problems. How would I make Razor to accept the UTF-8 files without a BOM ? Apparently the only solution would be to implement an own VirtualPathProvider and thus also a

跨平台导PDF,结合wkhtmltopdf很顺手

假装没事ソ 提交于 2021-01-24 13:30:18
前言 好东西要分享,之前一直在使用wkhtmltopdf进行pdf文件的生成,常用的方式就是先安装wkhtmltopdf,然后在程序中用命令的方式将对应的html生成pdf文件,简单而且方便;但重复的编码使得想在wkhtmltopdf基础上进行封装,偶然间发现有小伙伴已经封装的还不错啦,常用的功能都已经实现,源码地址:https://github.com/fpanaccia/Wkhtmltopdf.NetCore。 作者将其打包成Nuget包(Wkhtmltopdf.NetCore),直接引入使用即可; 正文 既然用到了.NetCore,肯定就要考虑到跨平台兼容性,对于wkhtmltopdf之前一直是在Windows上使用,还没有在其他平台尝试;这个包封装的行不行,拉出来遛遛就知道啦,接下来就试试: 1. 建个API项目,引入包和兼容对应平台的wkhtmltopdf执行文件 ; 注:默认依赖的wkhtmltopdf执行文件需要存放在Rotativa目录下,可以自定义名称,如果自定义,需要再注册服务时指定对应的文件名;这里的wkhtmltopdf已经根据不同平台进行编译打包了,无需安装,这些文件在源码那就有; 2.创建PDFTestController控制器,添加如下接口进行测试 ; 首先把生成pdf的服务注入进来,后续直接使用就可以啦: 接下来就开始写接口啦,这里只是测试

跨平台导PDF,结合wkhtmltopdf很顺手

£可爱£侵袭症+ 提交于 2021-01-24 12:52:04
前言 好东西要分享,之前一直在使用wkhtmltopdf进行pdf文件的生成,常用的方式就是先安装wkhtmltopdf,然后在程序中用命令的方式将对应的html生成pdf文件,简单而且方便;但重复的编码使得想在wkhtmltopdf基础上进行封装,偶然间发现有小伙伴已经封装的还不错啦,常用的功能都已经实现,源码地址:https://github.com/fpanaccia/Wkhtmltopdf.NetCore。 作者将其打包成Nuget包(Wkhtmltopdf.NetCore),直接引入使用即可; 正文 既然用到了.NetCore,肯定就要考虑到跨平台兼容性,对于wkhtmltopdf之前一直是在Windows上使用,还没有在其他平台尝试;这个包封装的行不行,拉出来遛遛就知道啦,接下来就试试: 1. 建个API项目,引入包和兼容对应平台的wkhtmltopdf执行文件 ; 注:默认依赖的wkhtmltopdf执行文件需要存放在Rotativa目录下,可以自定义名称,如果自定义,需要再注册服务时指定对应的文件名;这里的wkhtmltopdf已经根据不同平台进行编译打包了,无需安装,这些文件在源码那就有; 2.创建PDFTestController控制器,添加如下接口进行测试 ; 首先把生成pdf的服务注入进来,后续直接使用就可以啦: 接下来就开始写接口啦,这里只是测试

如何在 ASP.NET Core 中实现重定向

删除回忆录丶 提交于 2021-01-22 16:35:33
ASP.NET Core 是一个跨平台,开源的,轻量级的,模块化的,用于构建高性能的 web 开发框架, ASP.NET Core MVC 内置了多种方式将一个 request 请求跳转到指定的url,这篇文章我们就来讨论如何去实现。 理解 RedirectActionResult ASP.NET Core MVC 中内置了几种 Redirect,比如说:RedirectResult, RedirectToActionResult, RedirectToRouteResult 和 LocalRedirectResult,这些类都继承于 ActionResult 并可给前端返回 Http 302,Http 301,Http 307 和 Http 308 这些状态码。 接下来的文章中我们就来看看如何使用这些类。 使用 RedirectResult 可以使用下面任何一个方法来返回 RedirectResult。 Redirect 返回 Http 状态码为 302 RedirectPermanent 返回 Http 状态码为 301 RedirectPermanentPreserveMethod 返回 Http 状态码为 308 RedirectPreserveMethod 返回 Http 状态码为 307 具体状态码代表什么意思,大家可查专业资料,下面的代码展示了如何使用这些方法。

如何 ASP.NET Core 中实现重定向

拥有回忆 提交于 2021-01-22 13:54:06
ASP.NET Core 是一个跨平台,开源的,轻量级的,模块化的,用于构建高性能的 web 开发框架, ASP.NET Core MVC 内置了多种方式将一个 request 请求跳转到指定的url,这篇文章我们就来讨论如何去实现。 理解 RedirectActionResult ASP.NET Core MVC 中内置了几种 Redirect,比如说:RedirectResult, RedirectToActionResult, RedirectToRouteResult 和 LocalRedirectResult,这些类都继承于 ActionResult 并可给前端返回 Http 302,Http 301,Http 307 和 Http 308 这些状态码。 接下来的文章中我们就来看看如何使用这些类。 使用 RedirectResult 可以使用下面任何一个方法来返回 RedirectResult。 Redirect 返回 Http 状态码为 302 RedirectPermanent 返回 Http 状态码为 301 RedirectPermanentPreserveMethod 返回 Http 状态码为 308 RedirectPreserveMethod 返回 Http 状态码为 307 具体状态码代表什么意思,大家可查专业资料,下面的代码展示了如何使用这些方法。

jQuery Validate with Summernote Editor error: Cannot read property 'replace' of undefined

老子叫甜甜 提交于 2021-01-21 06:19:59
问题 I am using MVC5 to build a form with summernote editor. Razor code: <div class="form-group"> @Html.LabelFor(model => model.Content, htmlAttributes: new { @class = "control-label" }) @Html.EditorFor(model => model.Content, new { htmlAttributes = new { @class = "form-control post-content"} }) @Html.ValidationMessageFor(model => model.Content, "", new { @class = "text-danger" }) </div> JS: $('#blog-form .post-content').summernote({ height: 400, minHeight: 300, codemirror: { theme: 'default' } })

jQuery Validate with Summernote Editor error: Cannot read property 'replace' of undefined

和自甴很熟 提交于 2021-01-21 06:19:19
问题 I am using MVC5 to build a form with summernote editor. Razor code: <div class="form-group"> @Html.LabelFor(model => model.Content, htmlAttributes: new { @class = "control-label" }) @Html.EditorFor(model => model.Content, new { htmlAttributes = new { @class = "form-control post-content"} }) @Html.ValidationMessageFor(model => model.Content, "", new { @class = "text-danger" }) </div> JS: $('#blog-form .post-content').summernote({ height: 400, minHeight: 300, codemirror: { theme: 'default' } })

ASP.NET Core 入门教程 3、ASP.NET Core MVC路由入门

Deadly 提交于 2021-01-09 01:50:11
原文: ASP.NET Core 入门教程 3、ASP.NET Core MVC路由入门 一、前言 1、本教程主要内容 ASP.NET Core MVC控制器简介 ASP.NET Core MVC控制器操作简介 ASP.NET Core MVC控制器操作简介返回类型简介 ASP.NET Core MVC控制器操作简介返回类型示例 ASP.NET Core MVC控制器参数映射逻辑说明 ASP.NET Core MVC控制器参数映射/获取示例 2、本教程环境信息 软件/环境 说明 操作系统 Windows 10 SDK 2.1.401 ASP.NET Core 2.1.3 IDE Visual Studio Code 1.27 浏览器 Chrome 69 本篇代码以下代码进行调整: https://github.com/ken-io/asp.net-core-tutorial/tree/master/chapter-02 3、前置知识 你可能需要的前置知识 MVC框架/模式介绍 https://baike.baidu.com/item/mvc 二、ASP.NET Core MVC 控制器简介 1、ASP.NET Core MVC 控制器概述 在MVC Web框架中,路由模块会对接收到的请求进行匹配并转交由对应的控制器(Controller)进行处理。 控制器的作用就是处理接收到的请求