ASP.NET together with WCF Data Services or WCF Data Services - asp.net

Makes it sense to use ASP.NET togehter with WCF RIA Services or WCF Data Services ? Or are these technologies/frameworks only proper for Silverlight primarily ?

You can use RIA Services with ASP.NET, for example with DomainDataSource server control, or from an MVC controller.
The key thing is a DomainService in RIA Services encapsulates business logic in a presentation-tier neutral sense. It can be exposed as a service to Silverlight and Ajax apps, or it can be used by asp.net to do server-side rendering.
For example, a scenario is that of generating sitemaps and downlevel-rendering for SEO purposes, even if the presentation is silverlight-based. Both of these build on a domain service to share business logic.
Hope that helps.

Related

How to secure my asmx web methods only to be called by my asp.net web application?

I have a web application which is having an asmx web service holding some web methods. Those are being called through jQuery ajax method to get data or do various operations.
I want it to be accessed by only my web application and no other ways to call the web methods and this should be a fully secured one.
Can any body suggest on what are the security threats might affect my web methods and how i can protect them from those threats ?
Any suggestions are appreciated.
If you are using session state then you can use this
[WebMethod (EnableSession = true)]

Architecture Clarification for 3-tier web application

We are planning to use EXTJS framework for presentation layer which would be calling WCF based Rest Service or WebAPI Service(Http services) . My requirement is to have 3 tier architecture (physical separation) so my understanding is that we need to put Service layer on another server and host services on IIS there to be consumed by presentation layer hosted on different IIS server.
I am getting few doubts regarding this architecture.
Should we use Webform approach to host EXTS libraries as in this case ASP.Net MVC would be irrelevant considering that all the rendering logic is done by EXTJS.
If we host services on another server which service authentication should be used .In this case I think we can’t use Form Authentication as the web and service are hosted separately.
Is it really required to host Service layer on another server to make it three tier ,considering the third tier is the Database server. Isn’t browser a tier considering EXTJS library directly renders on the browser.
Since no body answered i will try to answer myself based on my research and response i got from another forum.
We can use MVC approach as well, the Controller method can be used to return JSON result for the EXTJS API to consume. But the downside is with this approach we cannot use strongly typed model in views along with other features like use of Html helper and automatic validation based on the models.
With this approach we can still use MVC routing or can go entirely with a Single View and ExtJs Routing.
Place the services your Ext.js needs on the web tier, where your Webforms/MVC application also runs. Separate your business logic/data logic via other services on another server if needed (second tier). Don't call these directly from your Ext.js. Keep presentation in the first/Web tier.We can use Form Authentication to call service in web-tier and Windows authentication to call the service from Webtier to second tier.
From the server side perspective a browser's not really considered a tier.However with modern approaches it's debatable.

how to cache data on wcf rest service depending on ASP.NET Membership token

We are developing an ASP.NET web application, this application will generate pages base on meta data (automatic page and controls generation), after this generation a javascript framework will load data for every control found on the generated page by invoking the WCF Rest service
my first question is : is it possible to share session data between the ASP.NET web application and WCF Rest service and how to do that? for the first uses we will deploy the ASP.NET web application and its service on the same machin to reduce complexity
my second question is : wich cache-framework you recommend to cache data on the WCF Rest services? we will not cache the output responses of the wcf service instead we will cache the modified user data on the service to simulate a user session
I would appreciate any help on how to deal with this problem
Thanks in advance
Regards
A good article on asp.net sessions from wcf
I don't have any problems with System.Web.HttpRuntime.Cache in WCF (I am only hosting the WCF in IIS - for sure). MemCache is very popular otherwise.

web services layer with combination of asp.NET web application

I have Data Tier, Business Tier which contains interfaces for the data tier, and presentation tier of asp.net web application.
I want to add web services (not wcf services!) that will use an interface.
Where should I put the interfaces for the web services?
Where should I put the web services implementation?
How can I combine the web services implementation with the asp.net web application?
Have you tried Web Service Software Factory (and on MSDN)? You can find guidance and best practices (even for asmx web services)
I like to think of asmx as a technology to expose functionality in your application. I write business services (BS) instead, unit testable, usable by a controller or aspx code-behind in your case or an asmx web service's implementation.
The asmx web service then exposes only the methods of the BS I want, it instantiate a BS and forward the result back to the caller (using its own "data contract" objects).
I would abstract them out and treat them just like data access (so at the same "level" as data access but in their own "slice").
See below for an answer on where to put an email component - which to me is exactly the same (in principle) as what your asking:
Does sending an email belong in the presentation layer or business layer of an application?

Common custom authentication for RIA, MVC and Web Service

I've got 3 different clients accessing my ASP.Net service layer. I'm in the process of moving the Silverlight client to RIA services and I'd like to consolidate my authentication code if possible. I use a custom table in my database to store user credentials and profile information.
Can an ASP.Net Membership Provider be used for RIA, MVC and Web Service applications? Or is there an easier way?
WCF: http://msdn.microsoft.com/en-us/library/ms731049.aspx
RIA: http://msdn.microsoft.com/en-us/library/ee707353(v=vs.91).aspx
ASP.Net MVC: http://www.asp.net/mvc/tutorials/authenticating-users-with-forms-authentication-cs
I got myself tied up in knots a bit trying to use the same auth mechanism for RIA and a WCF REST & SOAP endpoints; RIA is a WCF endpoint at the end of the day. However consuming a RIA service is more comparable to using an MVC app; call a login service after which the browser or Silverlight app automatically attach a cookie to all subsequent requests which will be authorised by the ASP.Net membership provider.
Conversely clients of the WCF SOAP and REST services there are better ways to authorise requests rather than force them to call a login service, extract the cookie and attach it to all future requests. The above link for WCF actually describes a mechanism where the username and password are set for every request. In practice a lot of public web API's require a single header with a secret key to be set.
My conclusion is that I'll use the same membership provider for ASP.Net MVC and RIA but a different mechanism for SOAP and REST WCF services.

Resources