我将EF Core和ASP Core 2.0一起使用。使用最新的身份框架。我在“全部”页面上收到此异常。
InvalidOperationException:属性“ User”不是实体类型“ Gallery”的导航属性。“ include(string)”方法只能与“。”一起使用。导航属性名称的分隔列表。
ApplicationUser看起来像:
public class ApplicationUser : IdentityUser<Guid>
{
public ICollection<Gallery> Galleries { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
实体图库如下所示:
public class Gallery
{
public int Id { get; set; }
public Guid UserId { get; set; }
public string Title { get; set; }
public int? ArticleId { get; set; }
public string Photos { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
public Article Article …Run Code Online (Sandbox Code Playgroud) 我在使用StreamReader和line != null添加时读取文件时遇到问题textBox1
码:
using(StreamReader reader = new StreamReader("lastupdate.txt"))
{
string line;
while((line = reader.ReadLine()) != null)
{
textBox1.Text = line;
}
reader.Close();
}
Run Code Online (Sandbox Code Playgroud)
它不起作用,我不知道为什么.我尝试使用using StreamReader,我从URL下载文件,我可以在文件夹中看到该文件已下载.该lastupdate.txt是大小1KB.
这是我当前的工作代码MessageBox.如果我删除MessageBox,代码不起作用.它需要某种等待或我不知道:
WebClient client = new WebClient();
client.DownloadFileAsync(new Uri(Settings.Default.patchCheck), "lastupdate.txt"); // ok
if(File.Exists("lastupdate.txt"))
{
MessageBox.Show("Lastupdate.txt exist");
using(StreamReader reader = new StreamReader("lastupdate.txt"))
{
string line;
while((line = reader.ReadLine()) != null)
{
textBox1.Text = line;
MessageBox.Show(line.ToString());
}
reader.Close();
}
File.Delete("lastupdate.txt");
}
Run Code Online (Sandbox Code Playgroud) 我试图弄清楚如何在子文件夹“admin”中工作,就像在根目录中工作一样,问题是我不知道该怎么做。
目前我有:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ?arg=$1 [L,QSA]
# /
RewriteCond %{REQUEST_URI} !\.[[:alnum:]]+$
RewriteRule ^(.+[^/])$ /$1/ [R=301]
Run Code Online (Sandbox Code Playgroud)
现在它的工作原理如下: http://example.com/page转换为http://example.com/?arg=page
我还想做的是: http://example.com/admin/page翻译成http://example.com/admin/?arg=page
我根本不知道如何实现这一点,有人可以帮助我吗?
谢谢
Blazor WASM 支持 gzip/brotli 压缩。官方文档显示了示例web.config ,但是此 web.config 未使用托管模型。
如果我将示例 web.config 与根 web.config 合并
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\app.Server.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
Javascript 文件、CSS、图像变得无法访问。我还尝试将示例 web.config 放入 wwwroot/_framework 文件夹中,但根本没有改变。
我正在关注本教程:http://www.mithunvp.com/create-aspnet-mvc-6-web-api-visual-studio-2015/
哪个应该是最新的,应该适用于rc2
信息:OS:Win 10 x64 14257 VS:15 Update 1 DNX:1.0.0-rc2-16357 clr x86
错误:
CS0592 Attribute 'FromServices' is not valid on this declaration type. It is only valid on 'parameter' declarations.
Run Code Online (Sandbox Code Playgroud)
WebAPIController
[Route("api")]
public class WebAPIController : Controller
{
[FromServices]
IWebAPIRepository WebAPI { get; set; }
[HttpPost("Authenticate", Name = "Authenticate")] // /api/Authenticate
public async Task<IActionResult> Authenticate([FromBody] LoginViewModel model)
{
if (model == null)
return Ok(new { success = false });
AuthenticationStatus result = await WebAPI.Authenticate(HttpContext.Authentication, model.Email, model.Password, model.RememberMe); …Run Code Online (Sandbox Code Playgroud) 我需要像这样创建容器:Container.Add(RowIndex,ValueIndex);
我知道词典只有关键和价值,这对我不利.我不知道如何使用2个容器创建Row,索引我想要的方式.
例如:
Container[Row][Index]:
Container[0][0] = "Apple";
Container[0][1] = "Orange";
Container[1][0] = "Number";
Run Code Online (Sandbox Code Playgroud)
因为我试图使用这个容器来读取sql.当我得到下一个结果时,它会添加到当前行值+1.和索引均值字段值.
在代码中:
int row = 0;
while (ObjReader.Read())
{
foreach (var result in ObjReader)
ReadList.Add(row, result.ToString());
row++;
}
ObjReader.NextResult();
Run Code Online (Sandbox Code Playgroud)
这是为了阅读
现在得到另一个班级的结果
public string Field(int row, int index)
{
return ReadList[row][index];
}
Run Code Online (Sandbox Code Playgroud) 你能帮我实现一个代表96位无符号整数的类吗?
我称这个类为Flag96.
码:
class Flag96
{
private object array = new uint[3];
public Flag96(uint a1, uint a2, uint a3)
{
uint[] _array = (uint[])array;
_array[0] = a1;
_array[2] = a2;
_array[3] = a3;
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用它时:
public Flag96[] example;
Run Code Online (Sandbox Code Playgroud)
不起作用.Microsoft定义的最大整数大小为64位,因此我需要一个新类.
c# ×5
.htaccess ×1
apache ×1
asp.net ×1
asp.net-core ×1
blazor ×1
brotli ×1
class ×1
compression ×1
containers ×1
indexing ×1
int ×1
ios ×1
mod-rewrite ×1
php ×1
readline ×1
row ×1
streamreader ×1
swift ×1
uibutton ×1
underline ×1
unsigned ×1
web-config ×1