Deploying MVC2 application to IIS7.5 - Ninject asked to provide controllers for content files - asp.net-mvc-2

I have an application that started life as an MVC (1.0) app in Visual Studio 2008 Sp1 with a bunch of Silverlight 3 projects as part of the site. Nothing fancy at all. Using Ninject for dependency injection (first version 2 beta, now the released version 2 with the MVC extensions).
With the release of .Net 4.0, VS2010, MVC2 etc., we decided to move the application to the newest platform. The conversion wizard in VS2010 apparently took care of everything, with one exception - it didn't change references to mvc1 to now point to mvc2, so I had to do that manually. Of course, this makes me think about other MVC2 things that could be missing from my app, that would be there if I did File -> New Project... But that is not the focus of this question.
When I deploy this application to the IIS 7.5 server (running on Win2008 R2 x64), the application as such works. However, images, scripts and other static content doesn't seem to exist. Of course they are there on disk on the server, but they don't show up in the client web browser.
I am fairly new to IIS, so the only trick I knew is to try to open the web page in a browser on the server, as that could give me more information. And here, finally, we meet our enemy. If I try to go directly to the URL of one of the images (http://server/Content/someimage.jpg for instance), I get the following error in the browser:
The IControllerFactory 'Ninject.Web.Mvc.NinjectControllerFactory' did not return a controller for a controller named 'Content'.
Aha. The web server tries to feed this request to MVC, who with its' default routing setup assumes Content to be a controller, and fails.
How can I get it to treat Content/ and Scripts/ (among others) as non-controllers and just pass through the static content? This of course works with Cassini on my developer machine, but as soon as I deploy, this problem hits.
I am using the last version of Ninject MVC 2 where the IoC tool should pass missing controllers to the base controller factory, but this has apparently not helped. I have also tried to add ignore routes for Content etc., but this apparently has no effect either. I am not even sure I am addressing the problem on the right level.
Does anyone know where to look to get this app going? I have full control of the web server so I can more or less do whatever I want to it, as long as it starts working.
Thanks!

I had a similar problem with StructureMap and favorite.ico what I ended up doing was to add a route to ignore that path.
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("favicon.ico");
Keep in mind that I have absolutely no idea really but another thing that changed is the need for Default.aspx, also if you have any custom pages those would need to mapped. That's the only two problems I had with routing.
routes.RouteExistingFiles = false;
EDIT: I meant that the RouteExistingFiles should be false otherwise I get that exception in MVC2 :)

Turns out this was caused by some account settings - I was unaware of the IIS AppPool\sitename account automatically being created by IIS in Win2008 R2 server. After trying "everything", I came across this information, gave the proper rights, and stuff magically started working.
Pretty hard thing to debug, especially for someone (me) with very limited IIS experience.

Related

SmartGWT DataSource adding QueryString to REST call

So, I have a Spring-MVC RESTful backend, that is cross-domain enabled. It is unit-tested, I can call my web-services and get back the correct JSON.
I have a SmartGWT 5.1p and GWT 2.7.0 front-end application that works great in SuperDev mode or Classic Dev Mode, either works great. When I do this, I am using the old Firefox 24 browser with the GWT plugin, and I can see my app work just great. My datasources are tied to RESTful web-services, and I can create, retrieve, update, and delete records via my DataSources.
I can compile the whole app via Maven, and get a WAR created just fine. I tried moving this WAR over to a tomcat server, and it deploys correctly. I can see the app running in tomcat with no errors in the logs.
Then when I go to the first page, the app comes up s normal with no errors. The first thing I do is add a username and password into a form, and then it is supposed to call a LoginDataSource which is tied into a LoginCOntroller, or login web-service.
What I can see from firebug is that when I make my call, rather than just calling:
http://mydomain:8080/admin/login/user/myusername/pwd/mypassword
I get:
http://mydomain:8080/admin/login/user/myusername/pwd/mypassword?0{and a whole lotta stuff after this) ... the query string I presume.
When I hit the Submit button, I get a SERVER TRANSPORT error, and that's it, I don't get any more information that that. There is nothing else to report from firebug except that the OPTIONS and GET add a whole lot of query string nonsense after the password.
I can look in the tomcat logs, and I don't see any errors in there at all. I don't even see the URL call to the web-service.
Any help on this would be much appreciated. I've been dealing with SmartGWT for years, and switched to back-end development for a while, and not I am trying to make my SmartGWT front-end work as well. But, I am a little rusty as to what is happening now.
Thanks!
The problem is not the querystring, it's the old base url I have in the datasource. There is a method in each datasource called: getServiceRoot
In getServiceRoot, I was using a hardcoded "localhost:8080", which in client code that doesn't work. That means whoever is running the app in their browser, "localhost" means their machine. So, I had to change the getServiceRoot to do the following:
protected String getServiceRoot()
{
String baseUrl = "http://" + Window.Location.getHostName();
return baseUrl + UrlConstants.SOME_URL_REST_ENDPOINT;
}
Since I have two WAR's on the same machine;
one WAR is a Spring MVC back-end RESTful web-services
the other WAR is the front-end, SmartGWT client application
This is a problem I run into ... I think just because both are on the same machine, that to the front-end, just call the code on the localhost, because it is there. But to the browser, that could be any other machine.
I suppose I could have just hard-coded the public IP address of the machine running tomcat, and then the client-side SmartGWT would then certainly find the RESTful web-services. Or, I could have used a Spring Env Profile to make that happen as well. But the code change I made should work, provided both WARS are on the same machine.
I just got to remember that client-side code in a browser is relevant to the machine the browser is running on.
So, this is fixed. If anyone needs any clarification, please let me know.

merge large existing web app into Sailjs site

I'm trying to merge large existing web app into sails.js. so I moved the folders into assets and build a custom route , 'GET /': '/assets/client/launch.html' and get 404 when I point my browser to http://localhost:1337/ as the / is correctly redirected to http://localhost:1337/assets/client/launch.html which produces the 404.
Now the file exists in the folder assets/client (and in .tmp), so I am thinking the Sails router is getting in the way.
I would leave the client (70K lines of JS) that generates all the UI dynamically and sailjs server that provides authentication separate and enable CORS but my customer wants client packaged with server. This type of operation is simple in frameworks like ASP.NET MVC but am wondering if Sails is up to the task.
Well, If everything you tried did not work out. There might be another solution ,
First of all since you are talking about sails app I am assuming other bundle must be sails as well ,
So here is what you do-
Change the port for another app that you want to attach to this.
Second whenever you want to go to page on another app simply redirect the client to another port ie
in html or esp put a href tag with different port.
<a href="localhost:PORT/route_to_file">
</a>
I got it working by placing my app into assets where we need to launch from assets/client/index.html as there would be too many dependencies to change. As I said above could not just add a route as Sails must getting in the way. However as in Chapter 3.2.2 of Sails in Action I generated a static asset npm install sails-generate-static --save. then I redirected to assets/client/index.html. As an aside that book is great and would highly recommend it.

LoadRunner and wicket application

Doing some research with regards to application framework used on the SUT am going to LoadTest using Loadrunner I fond the application is developed using wickets.
I have generated script using web http/html protocol against a wicket
application and there was some calls recorded in the following
format,script is failing at this URL when i ran the script in VUGen.
http://somem/nnnweb/main/ ?
wicket:interface= :1:someSearchForm :someSearchForm :searchInfo: :IActi
vePageBehaviorListener :0:&wicket: ignoreIfNotActiv e=true&random=
0.038901654740178815",
I find out like when i generate the script which has just views(
viewing tabs) is working fine, but when i edit somefileds and submit
the script is generating the above calls ( http://xxx...) and failing
This guy has explained just the same issue here:
http://tech.groups.yahoo.com/group/LoadRunner/message/27295
I hope it is ok to refer other sites in Stackoverflow?
General question. Does loadrunner support testing of wicket application and is TruClient the best choice here? I actually got it to work with TruClient, but as I understand there are drawbacks with memory footprint using TruClient, but maybe it is time to move on to next generation protocol given my project has decided to use wicket framework?

NServicebus MessageHandlers in a different Project don't get hit

My problem:
I have web project which implements NServicebus and should listen to messages.
Trying to keep my solution tidy I set up a different project for all my messagehandlers.
I now find that these messagehandlers do not get "hit" with messages.
To my understanding NServicebus scans all dll's in the debug folder of the web project to find any classes implementing IHandleMessages<>.
I referenced the messagehandlers class library project in my webproject and it appears in my debug folder, however it does not seem to get hit.
What does work
In a console sample project the inclusion of a referenced project which contains messagehandlers works as expected.
In my web app it works when I move my
messaghandlers to the web app project itself.
Reading through the website http://docs.particular.net/nservicebus/hosting/nservicebus-host/ I found that there are overloads for the Configure.With() method.
However:
I do not know if I need them. They text only seem to suggest that
this will limit the places where NServicebus looks for the
implementations of the interface.
these overloads do not exist in the Configure.WithWeb method which I'm using.
I can solve my problem by moving all the messagehandlers to my web project, but this does not seem like the best solution.
Am I missing something here?
When using NServiceBus in a web project, use NServiceBus.Configure.WithWeb() instead of NServiceBus.Configure.With().
Also, in order to load message handlers in a web application, you need to include the .LoadMessageHandlers() line after .UnicastBus() as described in Hosting NServiceBus in your own Process. Otherwise any IHandleMessages<T> implementations are not loaded and your web application operates as a send-only endpoint.

ASP.NET MVC2 IoC: Looking for an example using CastleWindsor container that works with minimum config

I am looking for an example of how to configure an ASP.NET MVC2 project to use CastleWindsor container to do IoC.
I keep running into problems setting it up, and for every problem there seems to be a solution on-line, but in the end I make so many changes and end up with such a verbose setup to get IoC working using CastleWindsor, that I thought it best to ask this question.
I am looking for the minimum configuration required in the Global.asax page, the Web.config, and if required, what other changes and extension classes are required.
I am not looking to inject into actionfilters at this stage, so just the basics. Preferably not using XML files, but doing it in .NET programatically.
Thank you in advance...
This is as basic as it gets:
Start a MVC2 project from VS2010
Download MvcContrib for MVC2 (the one that says "extra binaries")
In your project, add a reference to (all these DLLs are included in MvcContrib):
Castle.Core.dll
Castle.DynamicProxy2.dll
Castle.MicroKernel.dll
Castle.Windsor.dll
MvcContrib.dll
MvcContrib.Castle.dll
In your Application_Start(), add these lines (and whatever namespaces are needed):
var container = new WindsorContainer();
container.RegisterControllers(typeof(HomeController).Assembly);
ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container));