HTTP response status codes

HTTP response status codes indicate whether a specific HTTP request has been successfully completed.

Questions

Related Tags:
C# C# (pronounced "C-sharp") is an object-oriented programming language from Microsoft that aims to combine the computing power of C++ with the programming ease of Visual Basic. C# is based on C++ and contains features similar to those of Java. Learn More, React.js React (JavaScript library) In computing, React (also known as React.js or ReactJS) is a JavaScript library for building user interfaces. It is maintained by Facebook and a community of individual developers and companies. React can be used as a base in the development of single-page or mobile applications. Learn More, ASP.NET Core ASP.NET Core is a free and open-source web framework and successor to ASP.NET, developed by Microsoft. It is a modular framework that runs on both the full .NET Framework, on Windows, and the cross-platform .NET. However ASP.NET Core version 3 works only on .NET Core dropping support of the .NET Framework. Learn More, 415 Unsupported Media Type The HTTP 415 Unsupported Media Type client error response code indicates that the server refuses to accept the request because the payload format is in an unsupported format. Learn More, HTTP response status codes HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Learn More,

Question:Getting 415 "Unsupported Media Type" on post request from reactjs to asp.net core apicontroller ?

Description:I am getting 415 "Unsupported Media Type" on a post request, my reactjs submit method looks like the following one where I am sending data using FormData handleEmployeeSubmit(employee) { const data = new FormData(); data.append('FirstName', employee.firstName); data.append('MiddleName', employee.middleName); data.append('LastName', employee.lastName); data.append('Designation', employee.designation); data.append('Salary', Number(employee.salary)); const xhr = new XMLHttpRequest(); xhr.open('post', this.props.submitUrl, true); xhr.onload = () => this.loadEmployeesFromServer(); xhr.send(data); } and my APIController method look like the following one [HttpPost] [Route("Create")] public async Task<ActionResult> create([FromBody] Employee employee) { int empid = await _employeerepository.Create(employee); return Ok(empid); } any help will be appreciated as I am new to both reactjs and .net core

View Details

Posted by: Emerging Expert | Posted on: May 13, 2022


Related Tags:
Asp.Net It was developed by Microsoft to allow programmers to build dynamic web sites, web applications and web services. It was first released in January 2002 with version 1.0 of the .NET Framework, and is the successor to Microsoft's Active Server Pages (ASP) technology. Learn More, C# C# (pronounced "C-sharp") is an object-oriented programming language from Microsoft that aims to combine the computing power of C++ with the programming ease of Visual Basic. C# is based on C++ and contains features similar to those of Java. Learn More, ASP.NET MVC The ASP.NET MVC framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentication. The MVC framework is defined in the System.Web.Mvc assembly. Learn More, HTTP Response Status Code 301 HTTP 301. The HTTP response status code 301 Moved Permanently is used for permanent URL redirection, meaning current links or records using the URL that the response is received for should be updated. The new URL should be provided in the Location field included with the response. Learn More, HTTP Response Status Code 302 The HTTP response status code 302 Found is a common way of performing URL redirection. The HTTP/1.0 specification (RFC 1945) initially defined this code, and gave it the description phrase "Moved Temporarily" rather than "Found". Learn More, HTTP response status codes HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Learn More,

Question:how to redirect dynamically from mvc controller method with status code 301 instead of status code 302?

Description:In my code I am redirecting to new url which is current url appended with the url slugs but when I see in my browser it always gives status code 302 which is for temporary moved redirects but I need to move it permanently with status code 301 is it possible from controller method?

View Details

Posted by: Peter Andre | Posted on: Jan 25, 2019


1