当我运行离子应用程序时ionic serve -l
,得到此错误:
运行时错误
未捕获(承诺):cordova_not_available
堆
Error: Uncaught (in promise): cordova_not_available
at v (http://localhost:8100/build/polyfills.js:3:4864)
at s (http://localhost:8100/build/polyfills.js:3:4289)
at s (http://localhost:8100/build/polyfills.js:3:4112)
at http://localhost:8100/build/polyfills.js:3:4652
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:10284)
at Object.onInvokeTask (http://localhost:8100/build/main.js:38692:37)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:10220)
at e.runTask (http://localhost:8100/build/polyfills.js:3:7637)
at i (http://localhost:8100/build/polyfills.js:3:3707)
at HTMLDocument.invoke (http://localhost:8100/build/polyfills.js:3:11437)
Run Code Online (Sandbox Code Playgroud)
其他详情
Ionic Framework: 2.2.0
Ionic Native: 2.8.1
Ionic App Scripts: 1.1.4
Angular Core: 2.4.8
Angular Compiler CLI: 2.4.8
Node: 6.9.2
OS Platform: Windows 10
Navigator Platform: Win32
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like …
Run Code Online (Sandbox Code Playgroud) 我在我的项目中使用Automapper 5.2.0.当我ProjectTo()
在代码中使用时获取此错误:
Mapper未初始化.使用适当的配置调用Initialize.如果您正试图通过容器或以其它方式使用映射器实例,请确保您不必静态Mapper.Map方法的任何电话,如果你使用ProjectTo或UseAsDataSource扩展方法,确保你在适当的IConfigurationProvider通实例.
服务代码
public async Task<FreelancerProfileViewModel> GetFreelancerProfile()
{
var id = Guid.Parse(_identity.GetUserId());
var model = await _freelancerProfiles
.AsNoTracking()
.Where(_ => _.User.Id == id)
.ProjectTo<FreelancerProfileViewModel>()
.FirstAsync();
// var viewmodel = _mapper.Map<FreelancerProfileViewModel>(model);
return model;
}
Run Code Online (Sandbox Code Playgroud)
自动映射配置文件
public class FreelancerDashbordProfile : Profile
{
private readonly IIdentity _identity;
public FreelancerDashbordProfile(IIdentity identity)
{
_identity = identity;
var id = Guid.Parse(_identity.GetUserId());
CreateMap<FreelancerProfile, FreelancerProfileViewModel>()
.ForMember(_ => _.DoingProjectCount,
__ => __.MapFrom(_ => _.Projects.Count(project => project.ProjectState == ProjectState.Doing)))
.ForMember(_ => _.EndProjectCount,
__ => __.MapFrom(_ …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下原型编写API:
[HttpPost]
public ApplicationStatus appLogIn(string id, UserCredentials userCredentials = null)
Run Code Online (Sandbox Code Playgroud)
但是当我向这个API提出请求时,无论有没有userCredentials
,我都会得到以下错误,响应代码为500
{
"Message": "An error has occurred.",
"ExceptionMessage": "Optional parameter 'userCredentials' is not supported by 'FormatterParameterBinding'.",
"ExceptionType": "System.InvalidOperationException",
"StackTrace": null
}
Run Code Online (Sandbox Code Playgroud)
如果我不将userCredentials作为可选项,一切正常.userCredential定义如下:
public class UserCredentials
{
public string password { get; set; }
public string username { get; set; }
}
Run Code Online (Sandbox Code Playgroud) 我想用Angular材料创建RTL模板2但是,我不知道如何做这项工作?请帮我;
我有一个简单的.net核心应用程序,并通过以下命令发布它:
dotnet publish -c Release -r win10-x64
Run Code Online (Sandbox Code Playgroud)
SqlLocalDbStarter.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
当发布过程完成dotnet win10-x64
在bin\Release
文件夹中创建文件夹然后打开后,该文件夹包含publish
文件夹和一些dll和exe文件.
对我来说有一些问题:
exe
我需要PE应用程序中的哪一个文件(内部/外部发布文件夹)?exe
文件并将其移动到其他地方时它不会运行(没有消息)?dll
文件来运行应用程序,那么我有两个选项(内部/外部发布文件夹),内部发布文件夹大小为66 MB但外部发布文件夹为1 MB.exe
文件来运行我的程序没有DLL文件.当我在bootstrap 4中使用自定义输入文件时,请勿更改我的输入并且不显示browse
按钮.
<label class="custom-file">
<input type="file" id="Image" class="custom-file-input">
<span class="custom-file-control"></span>
</label>
Run Code Online (Sandbox Code Playgroud)
.custom文件
position: relative;
display: inline-block;
max-width: 100%;
height: 2.5rem;
cursor: pointer;
Run Code Online (Sandbox Code Playgroud)
.custom文件输入
min-width: 14rem;
max-width: 100%;
margin: 0;
filter: alpha(opacity=0);
opacity: 0;
Run Code Online (Sandbox Code Playgroud)
.custom文件控制
position: absolute;
top: 0;
left: 0;
right: 0;
z-index: 5;
height: 2.5rem;
padding: .5rem 1rem;
line-height: 1.5;
color: #555;
user-select: none;
background-color: #fff;
border: 1px solid #ddd;
border-radius: .25rem;
Run Code Online (Sandbox Code Playgroud)
我使用此示例验证我的表单,但出现此错误:
未捕获的TypeError:element.removeClass不是函数 说removeClass()不是函数!! 我糊涂了
我的Js代码:
$(function () {
var form = $('#CompanyStep')
, formData = $.data(form[0])
, settings = formData.validator.settings
, oldErrorPlacement = settings.errorPlacement
, oldSuccess = settings.success;
settings.errorPlacement = function (label, element) {
debugger;
oldErrorPlacement(label, element);
label.parents('.form-group').addClass('has-danger');
label.addClass('text-danger');
element.addClass('form-control-danger');
};
settings.success = function (label, element) {
debugger;
label.parents('.form-group').removeClass('has-danger');
label.parents('.form-group').addClass('has-success');
element.removeClass('form-control-danger');
element.addClass('form-control-success');
oldSuccess(label, element);
};
});
Run Code Online (Sandbox Code Playgroud) 我有一个Project.Api
引用另一个项目的项目Project.DomainModel
。当我通过运行构建要发布的 API 项目时
dotnet restore && dotnet build -c Release
Run Code Online (Sandbox Code Playgroud)
它构建成功。但是,当我尝试发布时
dotnet publish -c Release -o published --no-restore --no-build ./Project.Api
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
/usr/local/share/dotnet/sdk/2.1.302/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(168,5): error MSB3030: Could not copy the file "xxxx/Project.DomainModels/bin/Debug/netcoreapp2.1/Project.DomainModels.dll" because it was not found. [xxxx/Project.Api/Project.Api.csproj]
Run Code Online (Sandbox Code Playgroud)
根据错误,它正在Debug
目录中寻找引用的项目,但当然它不会在那里找到它,因为它会在Release
目录中。
Project.Api.csproj
文件如下所示:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Project.DomainModels\Project.DomainModels.csproj" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
知道为什么它在 Debug 目录而不是 Release 中查找吗?在 Mac 和 linux 机器上都得到这个。
我想将图像文件发送到控制器,但该文件HttpPostedFileBase
为空,我进入image: image
外部 JSON.stringify({})
但不起作用。另外,我改变contentType
并看到这个问题并使用它的答案,但我的问题没有解决。
var file_data = $("#Image").prop("files")[0];
var image = new FormData();
image.append("file", file_data);
$.ajax({
url: '@postUrl',
method: "POST",
contentType: 'application/json',
data:
JSON.stringify({
image: image,
isFirst : true,
ExternalProjects: ExternalProjects,
// more data
})
})
Run Code Online (Sandbox Code Playgroud) 我使用IIdentity
接口获取当前userid
和username
.
所以实现以下方法:
private static IIdentity GetIdentity()
{
if (HttpContext.Current != null && HttpContext.Current.User != null)
{
return HttpContext.Current.User.Identity;
}
return ClaimsPrincipal.Current != null ? ClaimsPrincipal.Current.Identity : null;
}
Run Code Online (Sandbox Code Playgroud)
并添加以下代码:_.For<IIdentity>().Use(() => GetIdentity());
我的IoC容器[structuremap]
.
用法
this._identity.GetUserId();
this._identity.GetUserName();
this._identity.IsAuthenticated
Run Code Online (Sandbox Code Playgroud)
现在我想实施GetEmailAdress
方法,如何做到这一点?
例
this._identity.GetEmailAdress();
Run Code Online (Sandbox Code Playgroud)
使用时this._identity.GetUserName();
不要获取用户名表格数据库.
c# ×4
angular ×2
asp.net-mvc ×2
javascript ×2
jquery ×2
.net-core ×1
ajax ×1
asp.net ×1
asp.net-core ×1
automapper-5 ×1
bootstrap-4 ×1
cordova ×1
css ×1
function ×1
html ×1
http-post ×1
identity ×1
ionic2 ×1
publish ×1
removeclass ×1
structuremap ×1
typescript ×1