How to integrate GWT with ASP.NET MVC3? - asp.net

I already have an ASP.NET MVC3 website, using Razor as the Views engine.
Is it possible to create the UI using GWT and invoke it as a View in my MVC3 website?
How is it done correctly?
Note: I know it easier to use JS API's such as JQuery or Google Closure to build UI in ASP.NET MVC3, but currently GWT is a requirement for the project.

The question is whether you want to go down the multi-page or the single-page road.
GWT is a toolkit which helps you create single page web-applications where the backend only serves as a datasource. This is a SOUI (Service Oriented User Interface) approach.
A single host page serves the GWT client application and you deal with flow synchronization and other user interface pattern (MVP) on the client side.
If you go down this road, you will probably not use any of ASP.NET MVC3's advanced features (specifically the model controller view part).
However it is also possible to use GWT in a multi-page setup where the backend takes care of the "flow synchronization" and you embed GWT as widgets in the corresponding views/pages.
You end up with small GWT apps for each host page/MVC view. You won't get all the optimizations in code-reuse because each host page will be a separate GWT app and thus shared code will be downloaded multiple times.
Regarding your specific question and the technical aspects of ASP.NET MVC3 and Razor:
I can't really comment on that because I don't have experience with ASP.NET MVC3. But in general GWT apps can be embedded in any web-page by simple including the nocache.js bootstrap file (if you want history support also embed the hidden iFrame).
See here for more details.
Note: this project could be also of interest to you.

Related

Integrate CMS like Umbraco in existing application

We develop very business-case specific applications, but all applications have something in common: some pages or some parts of pages need to be freely content-managed. We often rebuild the same functionality in each application: display and editing of CMS pages.
There must be a better way! Is there any .NET CMS that can be plugged in the way we can in the main application iterate on the available pages and display them using a simple API which outputs HTML, and management of those pages is done in the backoffice / administrative pages of the CMS application.
I would imagine, for example Umbraco, which offers an extensive backoffice. You would in the backoffice be able to add, remove and edit pages. The developer would in code simply use an API like:
UmbracoCms.Core.PageManager.GetPage('CONTENTBLOCK-HOME')
This would for example retrieve the HTML content for a content block on the home page.
Does anything like this exist in the .NET ecosystem, or are there alternative solutions? The basic question is here: How would you add CMS functionality (by preference, already from a well-known CMS like Orchard or Umbraco) into an existing web application without rebuilding and reinventing a wheel each time over and which solutions already exist? What solution would allow plugging in the CMS into the existing application instead of trying to get an existing application to work in a new CMS application?
If you have properly separated application, there would be no problem to integrate it with Orchard as module.
Modules in Orchard are like MVC area so it is like subapplication.
Separate business logic, domain entities and data access to separate libraries which will know nothing about Orchard. Create Orchard module just as presentation layer and as point for registering all your dependencies in Autofac IoC which is used by Orchard.
If your application is improperly designed ... ex .. all business logic is in controller, then you are in trouble.

What is the difference between ASP .NET Web Forms Applcation and ASP .NET Web Forms Site

I need to write a simple app which will work in a cloud where I can store data about clients and it will be avaiable from Windows and Android and I assume it has to be a website.
What is the difference between ASP .NET Web Forms Applcation and ASP .NET Web Forms Site? Which one should I use?
Web Form Site is nothing more than previously called Website projects where you work with webpages which is just small php like (with Razor/aspx) script files which render as html.
Webform is more like a component oriented framework. Web Form Site or WebSite should only be used for small projects or if the project needs to be compile in C#/VB both language. Also if you want to put your all source code in web-server then it can be used. On contrary with WebForm application you don't need to put code base files to run the projects - you'd be better off only putting scripting .aspx files.
This has been explained in detail in the following question:
ASP.NET Web Site or ASP.NET Web Application?
Also, you can check out the differences between the two here:
MSDN
Regarding your first question if your app is native or hybrid then you need REST(WebApi in .net world) which any app can access natively regardless of the device and will meet your needs of the "cloud".
If you what you want is a website instead that is "viewable" by mobile devices you may want to make your website "responsive" and you can look at various bootstraps templates that can help you with that.
Regarding your second question I think it has no bearing nor it will make any difference in creating a mobile app which project type you use.

How does the page-based model work in ASP.net?

I am reasonably familiar with C# desktop development and am very familiar with Rails, so ASP.NET MVC makes sense to me. However, I have a more lightweight site that I want to build in a manner more akin to dropping a bunch of .php files into a hierarchy of directories and having them be served up as just HTML files run through a pre-processor. (A full MVC stack and architecture seems like overkill for what is basically a brochure site.)
I believe it is possible to do this in ASP.NET (I remember the single .aspx pages approach from back in the day), but I'm not sure what this programming model is called in order to search for info on it--I can only find references to MVC and "web forms" in newer documentation.
I also would like to use pieces that are more popularly used in MVC, but in this more simple page-based model. For example, I would like to use Razor templates (with layouts and partials) and to access a single Model object that is shared across a number of templates.
I would appreciate any advice, or info on how to find documentation on using ASP.NET in this way.
The ASP.NET Web Pages framework supports web applications built using the Web Site project type* as well as Razor layouts and partials. It does not support strongly type models in the same way as MVC. However. that doesn't prevent you from taking a strongly typed approach to Web Pages development. The mechanism for passing data to partials is via the dynamic Page property (similar to ViewBag) which requires casting to get Intellisense support. Web Pages also lacks any kind of Model Binding support.
*This is the ASP.NET project type that does not require pre-compilation before deployment (as opposed to the Web Application project type). Web Forms apps can be built using either project type, but ASP.NET MVC apps can only be built using the Web Applications project type.

Are ASP.NET mobile views only for ASP.NET MVC? or can they be used in plain ASP.NET as well?

I know in ASP.NET MVC you can have mobile views and do things like Index.mobile.cshtml and _Layout.mobile.cshtml and the server knows to serve these views/pages to mobile devices rather than Index.cshtml and _Layout.cshtml, but can this also be done in plain ASP.NET websites (not using MVC)?
Note : I am using razor syntax in the plain ASP.NET website.
Thanks in advance.
-- Lee
UPDATE :
To clarify, I am aware of the various browser detection methods. My question is specifically about whether mobile views in the form Index.mobile.cshtml are available in plain ASP.NET.
UPDATE (Functionality now included in ASP.NET latest release announced 18th February 2013) :
Talk of the devil.. this is now possible in a recent release..
Scroll down the page to the heading 'ASP.NET Web Forms Enhancements'
http://weblogs.asp.net/scottgu/archive/2013/02/18/announcing-release-of-asp-net-and-web-tools-2012-2-update.aspx
Take a look at this, brief description of mobile support for ASP.NET Web Forms:
How To: Add Mobile Pages to Your ASP.NET Web Forms / MVC Application
My understanding is that the alternate view modes support native to MVC4 is a result of the WebPages2 used by MVC, and is currently only used within MVC to resolve locating Views via the View Engine (combination of VirtualPathProvider and DisplayModeProvider). This is because views served up via MVC and requests via the URI do not map to physical locations on the server to serve up files from. ASP.NET on the other hand serves up files directly based off of the URI, and does not depend on a virtual path provider the way MVC does.
My guess would be that ASP.NET does not support automatically serving up alternate files based off of the same framework that MVC uses. That being said, I'm sure it would be possible to derive an implementation based off of the of the logic of VirtualPathProviderViewEngine that could achieve a similar result with ASP.NET, however I know of no implementation that does this currently. Best suggestion would be to see if you can find usages of DisplayModeProvider and see if anything pops up.
I'm not an expert so feel free keep looking but I thought I would offer what I can.
So I have come to the conclusion that this is not built in functionality in plain ASP.NET.
Though there are (IMO less elegant) alternatives.
Are ASP.NET mobile views only for ASP.NET MVC? Yes.
Update : This may be possible in latest release
http://weblogs.asp.net/scottgu/archive/2013/02/18/announcing-release-of-asp-net-and-web-tools-2012-2-update.aspx
-- Lee

How to create an ASP.NET MVC 3 control/component that can be reused by other applications

I am required to deliver a component, inlcuding business logic and UI, to be used on a ASP.NET MVC 3 web site that is being developed by other company.
I know my way around ASP.NET WebForms server controls and how to package and distribute them to be reused across projects. I also have experience with MVC approach in general and some ASP.NET MVC experience. I did read over materials recommending use of HTML helpers and similar, but most of this deals with only UI reusability or reusability inside a single ASP.NET MVC project. I did not find any mentions of how to package and distribute such functionality for ASP.NET MVC.
The business logic is major part of this component. It is supposed to be a kind of wizard, which progresses through a lot of steps and which would also work with database using Entity Framework and send an email to the user upon completion.
How would I go about creating a control/component that encapsulates complex business logic and also renders its own UI/view output and that would be distributable in form of a standalone assembly? Is this even possible or only to some extend?
Would this somehow be doable by wrapping model, view and controller inside an assembly?
Or would it be better to approach this just as a complex model? If so, how would it be possible to connect the UI/view and controller to this component by the consumer of the component?
I also did see a couple of vendors out there, such as Telerik, who sell something along the lines of ASP.NET MVC controls/components, so I assume this is somehow possible to do.
This article tells how to call controllers from another assemblies.
To reuse only views, you can use RazorGenerator.
I recommend you to refer the MVC Control ToolKit Project page of CodePlex
Also see ASP.Net MVC Sprite Project

Resources