Guest User

Untitled

a guest
Jan 24th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. public void ConfigureServices(IServiceCollection services)
  2. {
  3. services.AddCors(options =>
  4. {
  5. options.AddPolicy("CorsPolicy",
  6. builder => builder
  7. .AllowAnyOrigin()
  8. .AllowAnyMethod()
  9. .AllowAnyHeader()
  10. .AllowCredentials()
  11. );
  12. });
  13.  
  14. .....
  15.  
  16. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  17. {
  18. app.UseCors(policyName: "CorsPolicy");
  19.  
  20. ....
  21.  
  22. [Route("api/[controller]")]
  23. [EnableCors("CorsPolicy")]
  24. public class ManageUsersController : Controller
  25. { ...
  26.  
  27. loginByPortal(credentials: Credentials): Observable<userLoginViewmodel> {
  28. const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
  29. return this.http
  30. .post(`${this.appConfig.apiEndpoint}/Account/LoginByPortal`, credentials,
  31. { headers: headers, withCredentials: true /* For CORS */ })
  32. .map(response => response || {})
  33. .catch((error: HttpErrorResponse) => Observable.throw(error));
  34. }
Add Comment
Please, Sign In to add comment