score:1
here is a very nice tutorial from the microsoft docs, using entity framework (very nice), and some dependency injection (very very nice).
basically you create an api controller class with your crud methods in them like so:
namespace myapicontrollerclass
{
[authorize]
[routeprefix("users")]
public class usersapicontroller : controllerbase
{
private readonly usercontext _context;
public usersapicontroller(usercontext context)
{
_context = context;
}
[route("/login")]
public ihttpactionresult loginuser(user user)
{
try
{
// login logic here
return ok(); // you can return whatever you need
}
catch (exception exception)
{
// log any issues using your preferred method of logging
return internalservererror(); // you can return different status codes as well. depends on what you want
}
}
}
}
you can read more about the authorize
annotation here and customize it to your liking.
then you fire up your web project which will be available at a local url that you can set in the project's configuration say http://localhost:4000/ which then makes your controller url available at http://localhost:34501/users/login. then you use this url in your javascript call and add the user object in the request body.
Source: stackoverflow.com
Related Query
- How do I create a HTTP post using React/Typescript Frontend and C#/.Net Backend?
- How to inject port and host using ENV variable in Create React App Proxy settings?
- How to create a preview (Image and description) to the Url when shared link on Social media,Gmail and Skype using React JS?
- how to put backend and frontend together - returning react frontend from fastapi backend endpoint
- how to build a standalone desktop app built with react, using a node backend, and wrap both frontend and backend in electron as a desktop app?
- how to display large list of data using reactJS as frontend and django rest framework as backend
- How to set up a chrome extension using React and TypeScript with multiple pages and entry points?
- How to create download feature using ASP.NET Core 2.1 and React JS?
- How to authenticate user from standalone react frontend with django backend (same domain, different ports), using a third-party CAS authentication?
- How to create list and detail view using React Router DOM?
- How to receive a file from frontend using post method and upload it to google cloud?
- How to update a post using react and redux
- How do I create an ag-Grid cell editor using React and TypeScript?
- How to integrate a react frontend and a separate php REST API backend
- How to loop through an array an put create an array of objects using react and javascript?
- How can I pass a value from the backend to a React frontend and use that value in the CSS for the frontend?
- How to send data and photo at same time to node js backend using axios in react js
- How to integrate Web MIDI API with React frontend and Django backend
- How to create a generic arrow function with react and typescript
- How to create a stopwatch in React using useReducer hook and setInterval?
- how to run react project with web pack which contains frontend and backend
- How to pass a json array that comes from backend to child component using props and react hooks?
- How to initialize an interface from API response using TypeScript and React
- How to create Loading bar during post request using React
- How can i post array of object using axios formik and react js
- Populate dropdown after http request using Typescript and React
- React How to handle checked and unchecked events for checkbox using typescript
- How to create email templates in React JS using Rails as backend
- What is correct way how to create functional component in react using typescript
- How to change form inputs in React and post using axios?
More Query from same tag
- dispatch action to close modal
- NextJS Mapping Array from Formik to Router.Push
- Is there a way to prevent redirection after form submission and still send the form data to the server?
- axios.get returns empty array in data
- CSS keyframe animation is not working on a react component
- Unable to Solve , Hooks can only be called inside of the body of a function component
- How to define time ranges in React?
- Can't display data from React Component
- Deploying create-react-app project isn't uglifying my code
- TypeError: item.name.toLowerCase(...).include is not a function reactjs
- How to pass json values into React component
- Erasing a character produces a bug
- React Slick slider map not showing slides?
- List Updates Incorrectly
- How to access value based on index from array defined in state ReactJS
- Component does not re-render although redux state is updated
- React Update Array of Object if Object has a matching value in another Array
- React.ReactNode to react element
- Mui react, I can't size my forms width properly
- Get values from useEffect hook and display in React's functional components
- Set classNames of React Transition Group with stage
- Enzyme shallow dive fails with connected component
- How do I associate seperate state to each button?
- 'LeafletProvider' is not exported from 'react-leaflet'
- Tailwind text color not changing on hover
- How to run string sequentially in typescript
- React + vitejs + storybook setup
- I am implementing an electron application using electron packager. However, it gives an error that it could not find the index.js file
- How can I calculate image overflow in the canvas, so I can limit the image editor to always be filled no matter the scale/position of image?
- Redirect to a URL fragment resets session on Chrome (Node/React/React-Router)