Silverlight - RIA Services Data/Service issue - silverlight-3.0

I have a baffling situation, which maybe you guys can help.
My RIA Solution does not retrieve the data from the service...
To give you an idea...
My domain service is derived from LinqToSqlDomainService and is in a Web Application project.
I had first created a RIA Services project with MVC and the Get query to the service (DomainContext) works great.
I then created a new RIA Solution, and used a Web Application project (instead of MVC to host the service), and this just does not get the data.
The Silverlight (RIA) client project is a copy of the working one and although I changed references, etc., I suspect there could be a problem in this project, either creating the HttpDomainClient:
this(new HttpDomainClient(new Uri("DataService.axd/FooAdmin-Web-FooDomainService/", System.UriKind.Relative)))
or in the LoadOperation:
loadOp = this._context.Load(this._context.GetFooQuery());
What are some ways, I can troubleshoot this and see what is failing?

You can use Fiddler to see the HTTP requests and possibly error codes.

Related

How to debug MVC web app with rest api controller backend? [duplicate]

In VS 2012, I am attempting to create an MVC 4 web application with jQuery calls to a Web API project. (Other devs will be consuming the API with our current, native app, and probably adding to the API in the future.) So I have one project that is the Web API, and another project that is the MVC 4 website. I can only set one of them to run, and they use localhost:xxxxx.
How do I debug changes to both? For example, let's say I add a new API path /api/customer/get and then a new jQuery ajax call to that path and do something with the resulting JSON. I've changed code in both projects and want to follow it end-to-end; how do I launch both? How do I debug both?
Just to be clear, the MVC app isn't making server-side calls to the API, I'm using MVC mostly to be able to easily use bundling, minification, and (hopefully) pre-compiled Handlebars templates in .NET; the API calls are coming from jQuery. As I am still relatively new to these technologies, alternate suggestions are welcome.
Thank you in advance.
I had the same problem and have found a solution from here:
forums.asp.net
The fix is to do the following:
In your solution file, click properties go to the Startup project node (if it is not already selected)
Next select Multiple startup projects. Select your website and your webservice and in the Action column make sure both of them have "Start" selected.
Now when you debug your website and put a break point in your webservice, it should hit the break point.
Coming late to the party but in case anyone else is looking for a solution, this is what was best for me: Set the Api project up to be the starting project (I needed to limit to one startup so that I could flip between browsers more easily). After firing up the service project, right click on the web/ui project and select debug, start new instance. You'll have both running and you'll seamlessly step from web to api.
I had a similar problem with my web api project. My solution consisted of an angular front end with 2 web api projects on the backend. One web api project handled "authorization" and the other handled "resources". I used the following tutorial by Taiseer Joudeh as a starting point:
http://bitoftech.net/2014/09/24/decouple-owin-authorization-server-resource-server-oauth-2-0-web-api/
Breakpoints worked on the "authorization server"... but not on the "resource server". I compared the packages from the two projects to see what was different. Once I added "Microsoft.AspNet.WebApi.Cors" to the "resource server" project, the breakpoints starting working.

Browser Links - Nonstop Signalr Calls in MVC 5 application

I've created a new MVC 5 Project in VS2013 and when I create the project I gave the authentication mode to none because I planned to use signalr in my project later.
I didn't install any signalr related files instead of the two signalr js files (in my scripts folder). And there are no any startup class or OWIN.
But when I run my application there are signalr calls going and going using longpooling. These things can be viewed in the firebug console.
Previously I've used signalr with many projects using VS 2012 MVC4 this is the first time I'm using MVC5. And this slows down my application. How this could be happened.
Here is the POST message...
Please help..
This is a dev tool only, it's not actually part of your application. I suggest you read this intro which also tells you how to disable the feature.

Calling Web API from MVC Application when both in same Solution

So I am totally new to the Web API and I thought to myself I would start a test project to learn it and AngularJS and how they can work together nicely ... etc.
I have created a multi-tier architecture within my solution, and inside my TPlan.API project, I have the following route configured in the Global.asax
GlobalConfiguration.Configuration.Routes.Add("default",
new HttpRoute("api/{controller}"));
TPlan.WEB is my MVC application, and it is set up as "Start Up Project". When I run it, I want to be able to go to:
mysite:port/api/test
And get the value from the API from my test controller in there.
However it is not working for me, I get the following:
No HTTP resource was found that matches the request URI 'mysite:port/api/test'.
Er, in visual studio, right click on the solution and go to properties.
Go to startup and select the "multiple projects" option and tick the website and the webservice to both start up.
That will start both of them. But as has been pointed out, they're running on separate ports, they're completely separate applications...
I don't think you can register a route that belongs outside of the website.
We work like this
View => POST / GET => MVC Controller => HTTP Request => API Controller
So our mvc views post or get to our mvc controllers, and then we fire off a separate http request to the web api. this is a server to server call, its like calling any external web service. we wait for the response from the api and then return whatever is required to the view...
What you are attempting isn't logically possible without installing your WebAPI project into IIS ahead of time, which I'm sure is not what you want. Both projects cannot be run at the same time, as only one project will be able to launch a debug session of IIS Express. Even if both projects were able to run at the same time, they would be on different logical ports, and routing from one project would have to be manually sent to the listening port of the other instance. Basically, your Global.asax on your API project will never run, as that project will be built as a class library.
Make your TPlan.API project a simple Assembly, reference it from TPlan.Web and pass the GlobalConfiguration.Configuration property over to a Register method that is in your API assembly. When the MVC project starts, both the MVC routes and the Web Api routes will be active on the same web host.
Here is an example of an API that has both a console host and a web host in the same solution.
Please check the following site. I believe the issue lies in the configuration of the route
http://www.asp.net/web-api/overview/extensibility/configuring-aspnet-web-api

Why is Ninject throwing a "did not return a controller" exception when deployed to Azure?

I've just deployed an MVC-based web service to Azure. It's been running fine on a dedicated server. It uses Ninject.
When deployed to Azure, I'm getting the following error:
The IControllerFactory 'xxx.NinjectControllerFactory' did not return a controller for the name '<DeploymentName>'.
where <DeploymentName> is the name of the production deployment (or hosted service - both have the same name) - which seems a little weird.
I'm using the latest version of Ninject from NuGet (2.2.0.0). My understanding was that there was a medium trust issue in 1.x, but not in 2.x.
Can anyone point me in the right direction on this one? As I said, it works fine in the non-Azure deployment - and I've used the same code in numerous MVC 3 web apps with no problems, so it does look like some Azure-specific issue.
I know that some projects run successfully on Azure that use Ninject.MVC3. You should try to use this extension rather than implement you own NinjectControllerFactory. Otherwise the problem is most likely in your ControllerFactory and not Ninject.

Why does ASP.NET MVC have to be a web application?

I'm wondering if anyone has any insight into why ASP.NET MVC sites have to be created as a web application (compiles to single .dll) in Visual Studio as opposed to a web site (each page is a .dll)? I suspect that it has something to do with the routing. Any thoughts?
Web Applications have a .csproj file which gives a lot better control over the build process when compared to a Web Site project which is really just a set of files and folders with build managed entirely by the VS IDE as far as i'm aware.
You may be right about the routing, but another possible reason relates to project structure and the relationship between the MVC application project and it's test project.
One of the key differences between a Web Application and a Web Site is that the Web Site is a standalobe entity, it does not exist within a solution which makes it difficult to express the relationship of the test project to the application project, whereas if a web application is used then the web site and it's tests can be treated as two projects within a common solution while also getting all the benefits of using MSBuild
Okay, I figured this out. The only reason that the ASP.NET MVC application is a Web Application instead of a Web Site has to do with the unit tests. You can 'convert' an ASP.NET MVC application to a web site with very little changes, but the unit tests won't work because they have no reference to the web site. But, I'm pretty sure that you can get the unit tests to work if you start pulling your application logic (controllers, et al) into a separate class library and then reference that class library in the web site and unit tests.

Resources