Adding a New REST Service Project to an ASP.Net MVC SPA - asp.net-mvc

I have been developing an ASP.Net Core 2.0 SPA web application in Visual Studio 2017 which started life using the new Angular SPA Template (ASP.Net Core SPA Templates). I now need to add reporting to the website and the Telerik Reporting solution I am trying requires a REST Service to function.
Telerik provide a VS 2017 template for their REST Service which I used to add a new .Net 4.6.1 Project to my Solution with its own ReportsController and associated references and code etc. The Telerik REST Service requires the full .Net framework.
My solution builds and runs, I can view my Angular web application, but if I use Postman to send a request to the new ReportsController I just get a 500 server error. I have added a reference in my SPA project to the REST Service project, which I may not require. Should I somehow configure the new REST Service in my SPA project's startup class?
How do I configure my solution such that the new REST Service is launched and listening for requests from my Angular web application please?

Related

Ninject Bindings with MVC5 sessions and Web API 2 sessionless in the same project

I've a ASP.NET MVC5 Web project where I use default MVC controller where I use InSessionScope bindings (works fine so far). I am using the
Ninject.Web.Common.WebHost
extension, wich creates the "NinjectWebCommon.cs" file in my "App_Data" folder.
Now I've added a Web API 2 controller to my project and the
Ninject.Web.WebApi.WebHost
extension.
But when I Call a Web API function, with my MVC5 bindings I get a error when I try to bind it to SessionScope.
so my question is, how can I create a seperate "NinjectWebCommon.cs" file or seperate bindings for my Web API 2 calls in the same project? Or how can I tell Ninject to bind my InSessionScope Bindings in RequestScope, when it calls my WebApi Controller / authentication, ....

How to set MVC web application as a SignalR self-host?

I have searched a lot about SignalR but all I could found that I can only make console application as a self-host and client from script and .net code can access that server. My question is how can we set a MVC Web application as a self-host?
Ref link.
Instead of adding only app.MapSignalR() to my Startup class I added app.UseCors(CorsOptions.AllowAll)as well and MVC based SignalR server is ready to server.

WCF service is added but, service reference instance is unavaiable into MVC 4 client applicaiton

I have crated WCF service.
Service client as - MVC 4 application. Added - Service reference into MVC 4 applicaiton.
Problem: In client application, unable to find - servicerefernececlient object to access service methods.
When i add same service reference into asp.net web applicaiton then it works and available to call service method. But, it is unavailable while access through MVC application.
DETAIL: In my solution there are three projects as follow: 1) WCF Applications ervice 2) ASP.NET Web Application 3) MVC 4 application.
WCF Applicaton service refernec added into both the projects using "Add service reference" . NOw, service reference instance is available into ASP.NET WEB applicaiton but, its not available into MVC 4 applicaiton.
Please suggest solution.
Please guide.
Thank You
can you describe it in more detail? The service reference is shown in your solution explorer like in a normal asp.net classic application? How do you generate the service client? Using Visual Studio via right-click > Add > Service Reference?

Why MVC in Durandal VS project template?

All the action is client side in a SPA app. The Visual Studio Durandal and Hot Towel project templates both serve the SPA out of an ASP.NET MVC application.
What, if anything, does the ASP.NET MVC infrastructure bring to the party? As far I can see all it does is make it hard to serve a WCF Web Service (ajax enabled) out of the project web.
Yet both of the project templates are set up like this. What have I missed?
As a matter of fact, ASP.NET MVC in this template is not necessary. All it does is serve the initial Razor template for the SPA and provides you with the bundling and optimization support of all the client side javascript resources for the application so that when you deploy your application you don't end up with gazillions of HTTP requests from the client to fetch all the .js crap necessary for the application to work. Of course you could perfectly fine have used the bundling feature outside of ASP.NET MVC in a simple and plain ASP.NET web application.
What, if anything, does the ASP.NET MVC infrastructure bring to the party?
See the documentation:
Hot Towel builds on the familiar and powerful ASP.NET MVC structure.
App_Start
Content
Controllers
Models
Scripts
Views
As far I can see all it does is make it hard to serve a WCF Web Service (ajax enabled) out of the project
You can't just right-click your project and add a new WCF Service?

Does asp.net MVC need to be compiled before it’s deployed onto a web server?

I can’t get a basic MVC site to work on my web server unless I’ve compiled it first in Visual Web Developer. If it doesn’t have a dll in the Bin, it says the Namespace can’t be found.
In classic asp.net I could just upload the files and the server would compile it at first run. Is this not the case in MVC? Essentially I’d like to build an MVC site without using Visual Web Developer.
That's cause ASP.NET MVC is not based on the Website model that many ASP.NET Web Forms apps were. It is based on the Web application model.
You can read about Web Application Projects here.
I've read about people migrating the Web Application to the Web site model in ASP.NET MVC but I don't recommended it.
Yes, you do need to compile an MVC site and deploy some DLLs in a bin folder when you deploy an MVC site
You can build MVC without Visual web developer... but why?

Resources