asp.net-core-mvc

Tag Helpers - Self closing HTML tags is a bad habit?

故事扮演 提交于 2019-12-19 09:00:01
问题 I am incorporating TagHelpers in my MVC vNext project, and I realized they don't work when I self close the HTML tags. @addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers" <label asp-for="FirstName"/> <!-- self closing tag --> <span asp-validation-for="FirstName"/> <!-- self closing tag --> And, insteand when I put the closing tags, I see the values being displayed. <label asp-for="FirstName"></label> <span asp-validation-for="FirstName"></span> Generated HTML <label for="FirstName">FirstName<

Change Global Settings Config in SignalR Core

对着背影说爱祢 提交于 2019-12-19 08:32:22
问题 I am using SignalR Core with ASP.Net Core . I want to override GlobalHost settings for signalR. I am getting this - protected void Application_Start(object sender, EventArgs e) { // Make long polling connections wait a maximum of 110 seconds for a // response. When that time expires, trigger a timeout command and // make the client reconnect. GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(110); // Wait a maximum of 30 seconds after a transport connection is lost // before

How can I upload a file in MVC 6 under vNext?

吃可爱长大的小学妹 提交于 2019-12-19 07:29:47
问题 In MVC 5 I used to do this: var context = (HttpContextBase)Request.Properties["MS_HttpContext"]; var file = (HttpPostedFileBase)context.Request.Files[0]; Now these are not available in MVC 6 under vNext. How can I get the file(s) from the request? 回答1: FileUpload isn't implemented in MVC6 yet, see this issue, and related issues such as this one for status. You can post an XMLHttpRequest from JavaScript and catch it with something like this code: public async Task<IActionResult> UploadFile() {

Angular JS MVC Web API Model/ Parameter not binding .NET Core

隐身守侯 提交于 2019-12-19 07:27:06
问题 I am using Angular JS with TypeScript and ASP.NET Core MVC/API. I have an apiService which deals with all POST and GET requests to the server, which looks like this: module TBApp { export class apiService { static $inject = ['$http', 'notificationService']; constructor(private $http, private notificationService: notificationService) { } get(url, config, success, failure) { return this.$http.get(url, config) .then(result => { this.handleResponse(result, success); }, result => { this

Getting blank pages for error messages with UseDeveloperExceptionPage enabled

£可爱£侵袭症+ 提交于 2019-12-19 06:57:37
问题 I'm getting blank pages for both when I enter an invalid URL, or when an exception is thrown within my application. I have UseDeveloperExceptionPage() enabled, and I have confirmed that my app environment is in development mode, and that the method is firing. The app works fine, but not having error messages displaying in the browser is frustrating. My Startup.cs Configure method: public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseIISPlatformHandler(); app

how to include views in asp.net 5 class library nuget package

微笑、不失礼 提交于 2019-12-19 06:38:48
问题 I'm creating a class library project that will contain some ViewComponents. It is nice that VS 2015 can automatically produce the NuGet package for me, but is there any way that I can make it include content files like .cshtml view files that my ViewComponents will need? Previously I've done packaging with batch files and nuspec files to make it include content, will I have to continue that approach or is there a way to tell VS 2015 about content files to include? 回答1: Not doable as yet. The

how to include views in asp.net 5 class library nuget package

China☆狼群 提交于 2019-12-19 06:38:31
问题 I'm creating a class library project that will contain some ViewComponents. It is nice that VS 2015 can automatically produce the NuGet package for me, but is there any way that I can make it include content files like .cshtml view files that my ViewComponents will need? Previously I've done packaging with batch files and nuspec files to make it include content, will I have to continue that approach or is there a way to tell VS 2015 about content files to include? 回答1: Not doable as yet. The

What should be stored in source control for an Asp.Net Core MVC application?

。_饼干妹妹 提交于 2019-12-19 05:23:32
问题 With the new Asp.net Core MVC projects such as: There are a lot of unfamiliar folders there, like bower_components , wwwroot , Dependencies , etc.. What should be stored in source control? 回答1: Anything that is a project setting, or that you directly change you should store. Anything that is directly downloaded (references, bower/node) or is directly based on those (lib folder getting copied by gulp) should be ignored. So, in your case, ignore bower, node, and project\wwwroot\lib. You want

Add existing assembly to an mvc 6 project

狂风中的少年 提交于 2019-12-19 03:59:21
问题 I'm testing Visual Studio 2015 and playing with mvc 6, all is fine, but when I try to add a reference, only proyects in the current solution are shown, I have an existing assembly already and I want to add it, but I don't see the option, how can I add a reference to a mvc 6 Project to an existing assembly? 回答1: I think Visual studio 2015 is in preview and we can not add reference that we used to do it Visual Studio 2013. For now onwards we add nuget package to Web Application ( ASP.net 5 or

Design-time T4 templates in ASP.NET 5 (VS 2015)

家住魔仙堡 提交于 2019-12-19 03:46:12
问题 I can't seem to find a way to make T4 templates in VS 2015 RTM, in an ASP.NET 5 (vNext) project. I even installed the T4 toolbox for Visual Studio 2015 extension, but the tt templates are not transformed. The property Custom Tool doesn't appear in the tt file properties, neither can't I find the ' Run Custom Tool ' command. Update The reason I want the T4 templates, is the introduction of the config.json file, and the pluggable configuration system, which is an awesome thing, but with the