This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
// Use Entity Framework in-memory provider for this sample | |
services.AddDbContext<ToDoListContext>(options => options.UseInMemoryDatabase("ToDoList")); | |
services.AddMvc().AddJsonOptions(options => | |
{ | |
options.SerializerSettings.ContractResolver = new DefaultContractResolver(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ToDoListContext : DbContext | |
{ | |
public ToDoListContext(DbContextOptions<ToDoListContext> options) : base(options) { } | |
public DbSet<ToDoList> ToDoLists { get; set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ToDoList | |
{ | |
public int ID { get; set; } | |
public string Item { get; set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { FormsModule } from '@angular/forms'; | |
import { HttpClientModule } from '@angular/common/http'; | |
import { RouterModule } from '@angular/router'; | |
import { AppComponent } from './app.component'; | |
import { NavMenuComponent } from './nav-menu/nav-menu.component'; | |
import { HomeComponent } from './home/home.component'; | |
import { CounterComponent } from './counter/counter.component'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>File Upload Using Angular 5 and ASP.NET Core 2.1</h1> | |
<input #file type="file" multiple (change)="upload(file.files)" /> | |
<br/> | |
<span style="font-weight:bold;color:green;" *ngIf="progress > 0 && progress < 100"> | |
{{progress}}% | |
</span> | |
<span style="font-weight:bold;color:green;" *ngIf="message"> | |
{{message}} | |
</span> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { HttpClient, HttpRequest, HttpEventType, HttpResponse } from '@angular/common/http' | |
@Component({ | |
selector: 'upload-component', | |
templateUrl: './upload.component.html' | |
}) | |
export class UploadComponent { | |
public progress: number; | |
public message: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Mvc; | |
using System.IO; | |
using System.Net.Http.Headers; | |
namespace Angular5FileUpload.Controllers | |
{ | |
[Produces("application/json")] | |
[Route("api/[controller]")] | |
public class UploadController : Controller |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GitHubController : ControllerBase | |
{ | |
[GitHubWebHook] | |
public IActionResult GitHub(string id, JObject data) | |
{ | |
if (!ModelState.IsValid) | |
{ | |
return BadRequest(ModelState); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DropBoxController : ControllerBase | |
{ | |
[DropboxWebHook] | |
public IActionResult Dropbox(string id, JObject data) | |
{ | |
if (!ModelState.IsValid) | |
{ | |
return BadRequest(ModelState); | |
} |