我无法获得所有标签的Intellisense(例如asp-for asp-action,等等)我正在运行Visual Studio 2017.
我的.csproj文件包括以下包:
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Tools" Version="1.1.0-preview4-final" Type=""/>
<PackageReference Include="Microsoft.AspNetCore.Razor" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="1.1.0" />
Run Code Online (Sandbox Code Playgroud)
我的_ViewImports.cshtml文件包括以下内容:
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
我需要编辑或添加一些东西吗?
我正在尝试将Bootstrap主题应用于我的数据表.我使用的是ngx-datatable10.4.0版,因为我仍然使用Angular 4而且11.0不兼容.根据更改日志,Bootstrap主题在版本10.3.0中添加.
以下是我的component.html:
<div>
<ngx-datatable class="bootstrap" [rows]="rows" [columns]="columns" (select)='onSelect($event)' [selected]="selected" [selectionType]="'single'"
[limit]="10" [columnMode]="'force'" [headerHeight]="40" [footerHeight]="40" [rowHeight]="'auto'">
</ngx-datatable>
</div>
Run Code Online (Sandbox Code Playgroud)
但是,这不会像演示中那样添加样式.我想我已经包含了文档显示的所有内容.
我正在使用Bootstrap 3.3.7.需要4.0吗?我没有正确包含某些内容吗?
我在两个单独的 ASP.NET Core 项目中使用WsFederation 。
每个项目都有以下内容Startup.cs
services.AddAuthentication(sharedOptions =>
{
sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme;
})
.AddWsFederation(options =>
{
options.Wtrealm = Configuration["Wtrealm"];
options.MetadataAddress = "http://example.com/metadata.xml";
options.SkipUnrecognizedRequests = true;
options.RequireHttpsMetadata = false;
options.UseTokenLifetime = false;
})
.AddCookie(options =>
{
options.Cookie.Name = "MySharedCookie";
options.Cookie.Path = "/";
options.Cookie.Domain = ".dev.example.com";
});
Run Code Online (Sandbox Code Playgroud)
我在浏览器中加载项目 #1,并得到我的 cookie:
然后,我导航到同一子域上的项目#2。但是,项目 #2 无法识别MySharedCookie并重新进行身份验证。我得到一个具有相同名称但不同值的新 cookie:
我想做的事情在 ASP.NET Core 中可行吗?在 ASP.NET Core 中有没有办法可以与项目 #2 共享项目 #1 的 cookie?
我有一个InputRadio如下所示的控件:
<InputRadioGroup Name="FooBar" @bind-Value="Foo.Bar">
<InputRadio Name="FooBar" Value=1 />Yes<br>
<InputRadio Name="FooBar" Value=0 />No<br>
</InputRadioGroup>
Run Code Online (Sandbox Code Playgroud)
Foo.Bar目前是可为空的,int因为看起来 anint是内置InputRadio控件绑定所期望的。我宁愿设置Foo.Bar为 nullablebool而不是 an int,因为我的应用程序有很多是/否问题,并且在代码中使用 true/false 会让事情变得更容易且更具可读性。
Blazor 中是否有一种方法可以对其进行配置,以便InputRadio控件可以绑定到 bool 值?
我正在使用JSONPlaceholder API:https://jsonplaceholder.typicode.com .我有以下内容service.ts:
public async getPosts(): Promise<Post[]> {
try {
const response = await this._http.get<Post[]>(this._baseUrl + "api/JsonPlaceholder/GetPosts");
return response.toPromise();
} catch (error) {
await this.handleError(error);
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试在我的component.ts:
public posts: Post[];
public async ngOnInit() {
const posts = await this._placeholderService.getPosts();
this.posts = posts;
}
Run Code Online (Sandbox Code Playgroud)
但是,TypeScript编译器会抛出错误public async getPosts(): Promise<Post[]>-Function lacks ending return statement and return type does not include 'undefined'.
它期望在catch块中或try-catch外部返回return语句.在我想要返回特定类型时,处理这类错误的最佳做法是什么......在我的情况下Post[].有没有更好的方法来构建这些类型的调用?
我正在尝试在inputText字段上设置一个默认值,该字段具有与之关联的dateTimeHelper.以下计算的默认值有效:
return @Today();
Run Code Online (Sandbox Code Playgroud)

但是,我需要在文档中以字符串形式存储的日期之后的7天设置默认日期值.所以我尝试了以下方法:
var date:NotesDateTime = session.createDateTime(doc.getItemValue("EffDate")[0]);
log.logEvent("date= " + date); // returns 09/01/2013
var newDate = new Date(date);
log.logEvent("newDate= " + newDate); // returns NaN
var datePlus7 = @Adjust(newDate,0,0,7,0,0,0,"[InLocalTime]");
log.logEvent("datePlus7= " + datePlus7); // returns NaN
return datePlus7;
Run Code Online (Sandbox Code Playgroud)
哪个不起作用,因为datePlus7是NaN.任何想法都非常感谢.
我正在尝试使用 AutoMapper 转换SourceThing为DestinationThing
public class SourceThing
{
public string Length;
public string Width;
public string Make;
}
public class DestinationThing
{
public int Length;
public int Width;
public string Make;
}
Run Code Online (Sandbox Code Playgroud)
CreateMap<SourceThing, DestinationThing>();
_mapper.Map<DestinationThing>(sourceObj);
我遇到的问题是当我sourceObj的情况如下:
{
"Length": "",
"Width": "2",
"Make": "3"
}
Run Code Online (Sandbox Code Playgroud)
我收到一个错误: FormatException: Input string was not in a correct format. AutoMapperMappingException: Error mapping types. Property: Length
是否需要配置一些东西以允许 AutoMapper 成功映射?
我有以下 FluentValidation 扩展方法来验证电话号码:
public static IRuleBuilderOptions<T, string> MatchPhoneNumber<T>(this IRuleBuilder<T, string> rule)
=> rule.Matches(@"^(1-)?\d{3}-\d{3}-\d{4}$").WithMessage("Invalid phone number");
Run Code Online (Sandbox Code Playgroud)
我称之为:
RuleFor(contact => contact.PhoneNumber).MatchPhoneNumber()
Run Code Online (Sandbox Code Playgroud)
但是,我只希望扩展方法在电话号码字符串不为空/空时验证电话号码。我可以通过执行以下操作来做到这一点:
RuleFor(contact => contact.PhoneNumber)
.MatchPhoneNumber()
.When(contact => !string.IsNullOrEmpty(contact.PhoneNumber));
Run Code Online (Sandbox Code Playgroud)
但有没有办法可以在扩展方法本身中做到这一点?
我需要设置一个具有两个可能值的单选按钮组的值.我能够用SSJS完成这个,但是通过CSJS设置它有问题.任何帮助表示赞赏.
我有一个禁用的复选框.我单击一个按钮,将该复选框的值设置为"已选中".当我去保存时,复选框丢失了它的值.有人有主意吗?这是一个简单的模型:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoDocument
var="MainForm"
formName="MainForm" />
</xp:this.data>
<xp:checkBox
text="CheckBox"
id="CheckBox"
value="#{MainForm.CheckBox}"
disabled="true"
checkedValue="Y"
uncheckedValue="N">
</xp:checkBox>
<xp:br></xp:br>
<xp:button
id="setBc"
value="Set CheckBox">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial"
refreshId="CheckBox">
<xp:this.action><![CDATA[#{javascript:getComponent("CheckBox").setValue("Y");}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button
value="Save"
id="button5">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:MainForm.save();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:view>
Run Code Online (Sandbox Code Playgroud) 我允许删除文件下载控件中的附件.如果用户删除附件并导航离开页面(不保存),则实际上不会删除附件.
控件有一个onclick事件,但并不特定于删除.有没有办法在删除附件后自动调用.save()?
xpages ×4
c# ×3
asp.net-core ×2
xpages-ssjs ×2
angular ×1
automapper ×1
blazor ×1
razor ×1
typescript ×1