我从源url克隆了该项目.我的朋友使用.NetCore 1.0.0-preview2-003121 sdk开发了asp.net核心Web应用程序.但是在我的电脑上我安装了.NetCore 1.0.1-preview2-003131 sdk.我收到了错误.我更改了global.json文件中的版本,如下所示,但仍然没有解决方案.我谷歌但是所有的解决方案都不适合我.
Global.json文件
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003131"
}
}
Run Code Online (Sandbox Code Playgroud)
Project.json
{
"userSecretsId": "aspnet-FMM-02f339eb-4af7-42c9-b7f3-d05b48d36811",
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": …Run Code Online (Sandbox Code Playgroud) 使用 jest-preset-angular 执行单元测试,但收到警告,因为UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON不确定导致错误的原因,因此应用程序卡住并且未运行其他单元测试。
PASS src/app/pages/result/result-filter/result-filter.component.spec.ts (6.251 s)
PASS src/app/pages/result/search-navigation/search-navigation.component.spec.ts
PASS src/app/pages/result/filter-modal/filter-modal.component.spec.ts (5.699 s)
PASS src/app/app.component.spec.ts
PASS src/app/pages/test-type/test-type.component.spec.ts (12.857 s)
(node:3280) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'element' -> object with constructor 'Object'
| property 'componentProvider' -> object with constructor 'Object'
--- property 'parent' closes the circle
at stringify (<anonymous>)
at writeChannelMessage (internal/child_process/serialization.js:117:20)
at process.target._send (internal/child_process.js:808:17)
at process.target.send (internal/child_process.js:706:19)
at reportSuccess (/Users/macbook/Projects/Playtime Projects/IDP/Idp.Bx.Ui/idp/node_modules/jest-worker/build/workers/processChild.js:67:11) …Run Code Online (Sandbox Code Playgroud) 我正在使用新的Android数据绑定,它工作得很好.我可以使用EditText,TextView,Radio和复选框执行数据绑定.现在,我无法在微调器中进行数据绑定.
在下面的链接中找到了一些线索: Android spinner数据绑定与xml布局
但是,仍然无法找到解决方案.还需要执行双向数据绑定.应该反映微调器数据的选择值.
有人可以给我一个例子吗?
这是我的xml代码:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View" />
<variable
name="viewModel"
type="com.ViewModels.model" />
</data>
<Spinner
android:id="@+id/assessmemt_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/carview_margin"
android:layout_toRightOf="@+id/text_bp"
android:drawSelectorOnTop="true"
android:spinnerMode="dropdown"
android:visibility="@{viewModel.type.equals(@string/spinner_type)? View.VISIBLE : View.GONE}" />
</layout>
Run Code Online (Sandbox Code Playgroud)
查看型号:
public class AssessmentGetViewModel {
private String valueWidth;
private ArrayList<String> values;
private String type;
public String getValueWidth() { return this.valueWidth; }
public void setValueWidth(String valueWidth) { this.valueWidth = valueWidth; }
public ArrayList<String> getvalues() { return this.values; }
public void setvalues(ArrayList<String> values) { this.values …Run Code Online (Sandbox Code Playgroud) 我使用下面的代码在ASP.NET Core 2.0中使用cookie进行身份验证
services
.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie("MyCookieMiddlewareInstance", options =>
{
options.AccessDeniedPath = new PathString("/Account/Login");
options.LoginPath = new PathString("/Account/Login");
options.LogoutPath = new PathString("/Account/LogOff");
});
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
未指定authenticationScheme,并且未找到DefaultChallengeScheme
Cookie设置如下:
var claims = new List<Claim>
{
new Claim(ClaimTypes.NameIdentifier, userId.ToString()),
new Claim(ClaimTypes.Name, userName)
};
var identity = new ClaimsIdentity(claims, "Forms");
identity.AddClaim(new Claim(ClaimTypes.Role, "ADMIN"));
var principal = new ClaimsPrincipal(identity);
HttpContext.Authentication.SignInAsync("MyCookieMiddlewareInstance", principal, new AuthenticationProperties
{
IsPersistent = isPersistent,
ExpiresUtc = DateTime.UtcNow.AddYears(1)
});
Run Code Online (Sandbox Code Playgroud)
我做了一些研究,没有找到解决方案.这是我使用的文档的链接:
任何人都可以让我知道如何解决这个问题?
我试图在asp.net核心中使用TempData但是我在TempData的get方法上得到一个null值.任何人都可以让我知道如何在asp.net核心中使用TempData
以下是我根据研究添加的内容.
Project.json文件
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
"Microsoft.EntityFrameworkCore.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0",
"DataBase": "1.0.0-*",
"UnitOfWork": "1.0.0-*",
"ViewModel": "1.0.0-*",
"Common": "1.0.0-*",
"System.IdentityModel.Tokens.Jwt": "5.0.0",
"Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.AspNetCore.Session": "1.1.0",
"Microsoft.Extensions.Caching.Memory": "1.1.0"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6", …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用角度为6的以下类来处理http错误.我从服务器获得了401 unAuthorized状态.但是,我没有看到控制台错误消息.
HttpErrorsHandler.ts文件
import { ErrorHandler, Injectable} from '@angular/core';
@Injectable()
export class HttpErrorsHandler implements ErrorHandler {
handleError(error: Error) {
// Do whatever you like with the error (send it to the server?)
// And log it to the console
console.error('It happens: ', error);
}
}
Run Code Online (Sandbox Code Playgroud)
app.module.ts文件
providers: [{provide: ErrorHandler, useClass: HttpErrorsHandler}],
Run Code Online (Sandbox Code Playgroud)
HttpCallFile
import { Injectable , Component} from '@angular/core';
import { HttpClient, HttpHeaders } from "@angular/common/http";
import { Observable } from 'rxjs';
import {AuthServiceJwt} from '../Common/sevice.auth.component';
@Injectable()
export class GenericHttpClientService …Run Code Online (Sandbox Code Playgroud) typescript angular-routing angular angular6 angular-errorhandler
我使用ASP.NET Core中的Entity Framework从现有数据库创建了模型.
这是Market表格的模型
public partial class Market
{
public Guid MarketId { get; set; }
public string City { get; set; }
public string CityF { get; set; }
public string Name { get; set; }
public string NameF { get; set; }
public int SortOrder { get; set; }
public bool IsActive { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
但是,我已将MarketId数据类型更改int为数据库中.现在我想更新模型.
找到一些链接,但此链接再次创建整个模型https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db
如何在不创建新模型和使用连接字符串的情况下更新模型appsettings.json?
我已经浏览了http://restsharp.org/代码,这些代码很有用.下面是带有asp.net核心的RestSharp的代码.
public GenericResponseObject<T> GetGeneric<T>(string operation, params KeyValuePair<string, string>[] nameValues) where T : class
{
RestClient client = new RestClient(_baseUrl)
{
Authenticator = new HttpBasicAuthenticator(_username, _password)
};
RestRequest request = new RestRequest(operation, Method.GET);
foreach (KeyValuePair<string, string> nameValue in nameValues)
{
request.AddQueryParameter(nameValue.Key, nameValue.Value);
}
IRestResponse<GenericResponseObject<T>> response = client.Execute<GenericResponseObject<T>>(request);
GenericResponseObject<T> responseObject = response.Data;
return responseObject;
}
}
Run Code Online (Sandbox Code Playgroud)
这段代码对我很有用.现在我想在asp.net核心中实现相同的代码.
我可以获得一个示例如何在asp.net核心中使用RestSharp.我添加了依赖项RestSharp.NetCore":105.2.3.
因为我使用的是 Java 14 和 15 预览功能。试图在java中找到字符串插值。
我找到的最接近的答案是
String.format("u1=%s;u2=%s;u3=%s;u4=%s;", u1, u2, u3, u4)
由于我从很多参考资料中得到的答案是 4,5 年前提出的旧答案。java 11,12,13,14,15 中的字符串插值是否有任何更新,相当于 C#
string name = "Horace";
int age = 34;
Console.WriteLine($"Your name is {name} and your age {age}");
Run Code Online (Sandbox Code Playgroud) 我不知道这个错误意味着什么.我,正在使用visual studio for mac 7.5.0社区版.从我开始,我在asp.net核心的实体框架中使用延迟加载.
public partial class AdminUser
{
public AdminUser()
{
RoleAssign = new HashSet<RoleAssign>();
}
public Guid UserId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string UserName { get; set; }
public byte[] Password { get; set; }
public DateTime CreatedTimeStamp { get; set; }
public DateTime? ModifiedTimeStamp { get; set; }
public DateTime? LogDate { get; set; …Run Code Online (Sandbox Code Playgroud) asp.net-core ×6
c# ×6
asp.net ×3
angular ×2
asp.net-mvc ×2
java ×2
typescript ×2
android ×1
angular6 ×1
java-15 ×1
javascript ×1
jestjs ×1
node.js ×1
restsharp ×1
string ×1