ASP.net WEB API (MVC5) [closed] - c#

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
This question is regarding Web API. I have a Mobile and a ASP.NET MVC5 web application. These application will interact with same DB. I thought instead of writing the code twice, we can have a WEB Api which will interact with DB and return data to the applications.
My Web API should be in MVC5 project/ Solution or I should have this API in separate solution and expose that API to both the application?

I would suggest to keep your Web Api and MVC Application in a single project. Just create a folder in your controller, for example Data, and keep your Api controller here, which must be derived from ApiController.
Then add a WebApiConfig.cs file in your App_Start folder and change the route for your Api's. (You just need to copy your route code from your Api project, if you have already, and place here.)
Then in your Global.asax.cs file, in Application_Start event, call your route for Api. You just need to add this line of code,
GlobalConfiguration.Configure(WebApiConfig.Register);
Then add all the required references for Api's through Nuget to your project, For example System.Web.Http;
That's it! Hope you understand :)

Related

Should I use different services for a different area in ASP.NET core? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 months ago.
Improve this question
So, I am using a classic MVC architecture with a service layer for my ASP.NET core app.
I added an Admin area and in it I added Controllers, Models and Views folders, so I can easily separate the admin-related stuff from the general user-related stuff. Now I have two options:
Creating a Services folder in my Admin area and literaly copy-pasting the already created services, but from my general Services folder
Directly using the already created services from the general Services folder
I am not sure which approach is generally accepted as better, so I hope for some guidance.
If you can use it as is, then the general Service folder is enough, but if you need to change/add many things than it is a good idea to create a separate service. (You can still use the general Service as a dependency in your admin service)

client/server authentiation: React client with C# web api [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I had an app that used an MVC template, prescaffolded with authentication (the one with bootstrap). I am migrating the project over to Web API and a React Client, but I still need this same functionality. The MVC authentication used SQL Server. I really want to do all I can the same, unless something better is possible. How can I implement authentication/authorization with Web API? I guess I can store the password in React's state/props, and then maybe pass that into the HTTP calls?
You can generate token using web api and then store it on react front-end in local storage. And whenever you do http call put that token in authorization header and match it from web api backend.

Modular .NET Core Web Application with AngularJS and WebAPI [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to working on the Single Page Application Based on .Net Core 2.0 with AngularJS for front-end. We have request that the application must be modular, which means that we must separate Back-end and front-end for each modules. We have been trying to find best approach for the project.
We try to use ASP.NET Boilerplate - Application Framework for this approach but i don't know how to support static files such as html and JavaScript files for angular per modules and We cannot configured Main Web-app to lookup static files in different location (modules must separate with project files).
I cannot find examples for this case (Modular App Based on .NET core and WebAPI and AngularJS,Typescript ...). Do anybody have suggestion how can we solve this problem, or do you suggest another approach or framework or sample code.
Note: The main problem is add routing With angularJS in Modules when modules are load in Main application start up Event.

Combine ASP.NET WebForms with DotVVM in single project [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
currently I have the web application using Web.Forms. It consist of more than thousand pages and rewriting everything from scratch will be extremely time consuming.
I'm planning to gradually rewrite each page while the others remains as webforms.
Is that even possible? Having mix of DotVVM and Web.Forms pages within single project?
What would you suggest to start with? Ideally I'd like users not to even know that the page looks different. I don't care about URLs as it's admin application.
From what I learned so far I need to duplicate my current MasterPage to the .dotmaster page and then add views for pages I am rewriting.
Thanks for suggestions.
I have created a sample app which shows how to combine ASP.NET Web Forms and DotVVM in one project.
Basically you need to install DotVVM.Owin and Microsoft.Owin.Host.SystemWeb packages in the project, add the OWIN Startup class where you register DotVVM middleware, and add the project type GUID in the .csproj file to make the Visual Studio extension for DotVVM work.

How to reduce boilerplate code for web api calls? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am working with a ASP.NET MVC website and ASP.NET Web Api service. Current architecture looks like this
Browser => UI website => Web Api service => databases
The argument to split UI and Web Api was so that we can have several different UIs (Web, Mobile, Desktop, watches, etc) all calling intermediate service to get data. However, when I need to add a new api call i need to add quite a bit of plumbing boilerplate code (+ boilerplate tests which I dislike even more).
Browser => ajax
UI => controller and web api proxy client
Web API => controller and repository
database
I am thinking, it would have been easier to combine web api with UI, as I won't need to write additional controllers and proxy to call it, however I am not sure if this is the right way to go. We have about 20 controllers and 100 api calls written in C#. I am interested to know how other people use web api together with UI projects.
Should I merge Web Api project with UI project and what are the pros and cons of doing so?

Categories