发布后,我的Umbraco管理面板没有在IE9中显示.但它出现在FF和Chrome浏览器中.
注意:在发布网站之前,我从Visual Studio 2012运行它,我发现一切都很好.
谁能帮我?
使用时如何访问AddOrUpdate()
方法ASP.NET Core 2
?
有AddOrUpdate()
在EntityFramework 6
在System.Data.Entity.Migrations
命名空间。但是当我想在 中使用这种方法时ASP.NET Core 2
,我找不到它。
当我创建Controller
和View
通过MVC Controller with views, using Entity Framework
我得到了一个错误。
错误是:
运行所选代码生成器时发生错误:“无法加载文件或程序集Microsoft.EntityFrameworkCore,版本= 2.0.1.0,Culture = neutral,PublicKeyToken = adb9793829ddae60”,找到的程序集的清单定义与程序集引用不匹配
我怎么解决这个问题?
我使用的Visual Studio Version 15.5.2
版本Microsoft.AspNetCore.All
是2.0.0
asp.net-mvc-scaffolding asp.net-core-mvc asp.net-core asp.net-core-2.0
我想在C#块代码之间使用html标签,我试过但是我遇到了错误.如何在cshtml文件中的C#块代码之间插入html标签?
错误是:
只有赋值调用增量递减和新对象表达式才能用作语句
@{
Func<List<Comment>, Comment, HelperResult> ShowTree = null;
ShowTree = (items, node) =>
{
@<text>
<ul>
@foreach (var comment in items)
{
}
</ul>
</text>;
return null;
};
}
Run Code Online (Sandbox Code Playgroud)
更新2:
我已经使用@:
但仍有问题.那是;expected
我怎么解决这个问题?
@{
Func<List<Comment>, Comment, int, HelperResult> ShowTree = null;
ShowTree = (items, parentItem, parentId) =>
{
var count = items.Count(p => p.ParentId == parentId);
if (count > 0)
{
@:<ul>
foreach (var item in items.Where(p => p.ParentId ==
parentId).ToList())
{
@:<li>
string …
Run Code Online (Sandbox Code Playgroud) razor asp.net-core-mvc asp.net-core asp.net-core-2.0 razor-pages
如何向 SelectPdf 转换器添加/引入 CSS 文件?
我使用SelectPdf库将 HTML 字符串转换为 PDF 文件。
我的 CSS 文件位于cssFilePath
public byte[] Create(string htmlString)
{
string cssFilePath = Path.Combine(Directory.GetCurrentDirectory(), "assets", "PruefReportDataTableFormat.css");
string pdf_page_size = "A4";
PdfPageSize pageSize = (PdfPageSize)Enum.Parse(typeof(PdfPageSize), pdf_page_size, true);
string pdf_orientation = "Portrait";
PdfPageOrientation pdfOrientation = (PdfPageOrientation)Enum.Parse(typeof(PdfPageOrientation), pdf_orientation, true);
int webPageWidth = 1024;
int webPageHeight = 0;
HtmlToPdf converter = new HtmlToPdf();
converter.Options.PdfPageSize = pageSize;
converter.Options.PdfPageOrientation = pdfOrientation;
converter.Options.WebPageWidth = webPageWidth;
converter.Options.WebPageHeight = webPageHeight;
PdfDocument doc = converter.ConvertHtmlString(htmlString);
byte[] result = doc.Save(); …
Run Code Online (Sandbox Code Playgroud) 我想在应用 TinyMCE 时强制提交文本区域。
如果我给 加上required
属性<textarea>
,会导致即使填了也无法提交!
我怎么解决这个问题?
tinymce.init({
selector: '#summaryId',
max_chars: 255, // max. allowed chars
plugins: "paste",
setup: function (ed) {
var allowedKeys = [8, 37, 38, 39, 40, 46]; // backspace, delete and cursor keys
ed.on('keydown', function (e) {
if (allowedKeys.indexOf(e.keyCode) != -1) return true;
if (tinymce_getContentLength() + 1 > this.settings.max_chars) {
e.preventDefault();
e.stopPropagation();
return false;
}
return true;
});
ed.on('keyup', function (e) {
tinymce_updateCharCounter(this, tinymce_getContentLength());
});
},
init_instance_callback: function () { // initialize counter …
Run Code Online (Sandbox Code Playgroud) 我在我的项目中应用了 ASP.NET Core 3.1,我想通过代码优先的方法创建数据库并使用 MySQL。在 startup.cs 文件中,我收到此错误:
CS1061“MySQLDbContextOptionsBuilder”不包含“ServerVersion”的定义,并且没有可访问的扩展方法“ServerVersion”接受“MySQLDbContextOptionsBuilder”类型的第一个参数
我该如何解决?
在startup.cs中:
using Microsoft.EntityFrameworkCore;
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContextPool<Alpha.Web.App.ApplicationDbContext>(options =>
options.UseMySQL(Configuration["ConnectionStrings:DefaultConnection"],
mysqlOptions =>
{
mysqlOptions.ServerVersion(new Version(8, 0, 20), ServerType.MySql);
}));
}
Run Code Online (Sandbox Code Playgroud) dbcontext entity-framework-core asp.net-core asp.net-core-3.0
我想将一些代码升级到ASP.NET Core 2
. 我知道HttpContext.Current
已从 中删除ASP.NET Core 2
并且必须使用IHttpContextAccessor
.
但我不知道应该如何替换这段代码:
HttpContext.Current.Items.Contains(DataContextKey)
我该怎么做?
完整代码:
namespace Jahan.Infrastructure.DataAccess.DataContextStorage
{
public class HttpDataContextStorageContainer<T> : IDataContextStorageContainer<T> where T : class
{
private const string DataContextKey = "DataContext";
public T GetDataContext()
{
T objectContext = null;
if (HttpContext.Current.Items.Contains(DataContextKey))
{
objectContext = (T)HttpContext.Current.Items[DataContextKey];
}
return objectContext;
}
public void Clear()
{
if (HttpContext.Current.Items.Contains(DataContextKey))
{
HttpContext.Current.Items[DataContextKey] = null;
}
}
public void Store(T objectContext)
{
if (HttpContext.Current.Items.Contains(DataContextKey))
{
HttpContext.Current.Items[DataContextKey] = objectContext;
} …
Run Code Online (Sandbox Code Playgroud) 有相当于Response.Redirect("~/Controller/")
in Asp.Net Core 2
吗?
我不想用ViewComponent
。相反,我想从视图中调用Controller和action方法。
@using Jahan.Blog.Web.Mvc.Models
@{
ViewBag.Title = "Home Page";
}
<header>
<h1> Blog </h1>
</header>
<div class="blog-description">
<p>...</p>
</div>
@{ Response.Redirect("~/Article/");}
Run Code Online (Sandbox Code Playgroud) 如何在 EF Core 2 中的自引用表中实现级联删除(代码优先)?
(例如,有一个评论表,一个人可以回复一条评论,这个回复可以由另一个人回复。)
public class Comment
{
public virtual int Id { get; set; }
public virtual int? ParentId { get; set; }
public Comment Parent { get; set; }
public virtual IList<Comment> Replies { get; set; }
public virtual string Description { get; set; }
public virtual Article Article { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
entity-framework cascade entity-framework-core ef-core-2.0 entity-framework-migrations
asp.net-core ×5
asp.net ×2
c# ×2
razor-pages ×2
cascade ×1
converters ×1
dbcontext ×1
ef-core-2.0 ×1
entity-framework-migrations ×1
form-submit ×1
html ×1
html-to-pdf ×1
javascript ×1
razor ×1
selectpdf ×1
tinymce ×1
umbraco ×1
web ×1