WebApi EntitySetController using composite keys - asp.net-web-api

The excellent sample code: Support Composite Key in ASP.NET Web API OData
illustrates how to create routing conventions to make WebApi OData work with composite keys.
However it is using ODataController (as one of the unanswered discussions on the sample code mentions) which I presume has many downsides (which I am yet to fully uncover)... has anyone created an example using the benefits of EntitySetController?

Going forward the recommended approach is to directly derive from ODataController. Visual Studio 2013 provides scaffolding for creating OData services based on ODataController. This has been found to be a much more flexible model than deriving from EntitySetController. You get complete control over what is done in your actions.

Related

Host an ASP.NET Core MVC application in an Azure Function

I have tried searching for this online, but could not find an approach that works. There are a few helpful links to host a Web API but nothing related to a full fledged MVC app that consists of Controllers and Views. Azure currently does not have built in support for this. Hence, wondering if this is something doable.
It is possible to achieve this through the use of Custom Handlers. This blog post goes into further detail on how to create a custom handler. Do note that this feature is currently in preview so support is limited.

Validating Azure Functions CRUD operations

I have just started to look at Azure Functions and one of my biggest concerns currently is validation.
I have only really looked at the CRUD operations so far, but there doesn't look like a way to easily validate data coming from the request or into the storage.
I have found this poco-validation and thought it might be useful.
I know this is kind of and open ended question but I'd be interested to see what others was doing for validation.
We recently added Function Filters to the underlying WebJobs SDK but that feature isn't fully exposed yet in Azure Functions (see issue here). Related to this, we're also considering support for validation annotations to be applied to your POCO types (issue here).
Until the above issues are addressed, we realize the story for validation isn't great. The recommended approach is to perform required validation in your function code calling out to shared validation helpers/code as needed.

MVC5 to use custom membership or my own implemenation?

I'm starting a new project and intending(I actually started implementation) to use MVC 5 and most recent microsoft technologies. In my DB, I have my own table to manage user accounts and storing passwords and I have no problem or complexity doing that.
But(and there always but), most tutorials I see on MVC use .NET Membership. Every tutorial I read to learn about the new fetures is using it. This gives me a feeling that I should too be using it or at least write a custom implementation of it.
Am I looking to it wrongly? Am I missing something here? Do I need to take the development process little bit slower?
I really confused and I'm not sure which path to take specially I'm still at the start of my project.
I would suggest using Asp Identity 2 which replaces the old Asp Membership, with the account functionality scaffolded when you create a new MVC 5 Web application. It gives you heaps of functionality straight out of the box.
Of course, it depends on your requirements, but this is a pretty robust way to get started. It easily allows you to intergrate other OAuth providers like Facebook etc.
Here are some helpful resources:
http://blogs.msdn.com/b/webdev/archive/2013/06/27/introducing-asp-net-identity-membership-system-for-asp-net-applications.aspx
http://blogs.msdn.com/b/webdev/archive/2013/10/16/customizing-profile-information-in-asp-net-identity-in-vs-2013-templates.aspx
http://msdn.microsoft.com/en-us/data/jj200620.aspx
You can map your current user table to the IdentityUser if they follow the same structure.
http://coderdiaries.com/2014/01/29/custom-table-names-for-asp-net-identity/

What new features would you like to see in Asp.net MVC 3?

Asp.net MVC 3 preview 1 was released at the end of last month. Are there any new features you are excited about or any features you would like to see before it is fully released?
Full support for Controllers with Generic Parameters
public GenericController<SomeType> : Controller
Generic controllers are quite possibly the greatest MVC timesaver if your doing a lot or business CRUD. There are so many similarities between the Add methods of almost every MVC project that it makes sense to abstract these operations out in a Controller that fits all scenarios.
Right now its a little hacky to create a generic controller. The MVC engine always gets the name wrong (GenericCo vs. Generic) and without full support plugin and libraries that interact with controllers just fall over when they encounter a generic one.
Make Dropdowns easier to work with
As a professional MVC tag watcher I've noticed that working with dropdowns is one of the most repeated questions on SO. The amount of Dropdown questions is a strong indication that something should be done to make it easier or less ... complex?
make checkbox list easy to work with
add T4MVC to the official release
add official helpers for OData
support one javascript library either MS Ajax or jQuery(preferably)
I wish they can add something to help developer to migrate their previous ASP.NET WebForms application.

What's an alternative to MVC?

Seems like every project I'm on uses a Model View Controller architecture, and that's how I roll my own projects. Is there an alternative? How else would one create an application that has persistent storage and a user interface?
MVC has been around for a while. It's a time tested and proven pattern. Many frameworks leverage the MVC Pattern. Martin Fowler has deconstructed the MVC into: Supervising Presenter and Passive View.
Architect Christopher Alexander said it best:
Each pattern describes a problem which
occurs over and over again in our
environment and then describes the
core of the solution to that problem,
in such a way that you can use this
solution a million times over, without
ever doing it the same way twice.
I'm not sure why you would want to move from MVC. Is there a problem you are encountering that MVC does not eloquently solve? To give you a better answer we need to know more about your problem domain.
Things to take into account when considering patterns/architecture: If you are building something with a Myspace type architecture you'll need a robust architecture (MVC). If you are creating a simple crud interface via the web - almost anything will do.
For .Net Web forms (I am assuming web, since you didn't say thick or web client) which is not MVC, it was a nightmare maintaining them. Web Forms applications that lived more that a couple years tended to become big balls of mud. Even then developers discovered ways to use MVC with web forms.
Ironically, the lack of MVC architecture in ASP.NET web forms was one of the driving complaints that lead to the development of ASP.Net MVC framework.
From experience if you don't use some MVCesk approach, your solutions become hard to maintain and bloated. These applications will die a slow painful death.
If your solutions are small one-off projects, the by all means throw something together. Heck there are tools that will generate everything from the screens to the data access layer. Whatever works to get the job done.
Classic CRUD apps built using tools like VB6 and Delphi have user interfaces, persistent storage and don't use MVC. Most of them used data aware controls linked directly to database fields
Couple of links comparing various MV* patterns which might be useful:WPF patterns : MVC, MVP or MVVM or…? & MVC, MVP and MVVM
Look into MVP model view presenter.
User interface is View and an application will always have a model and the bridge between the two is Controller. The whole MVC is nothing special as this is how the things will be always.
At the most you can get rid of Controller and have your view talk to your model but you loose the flexibility.
I've developed an alternative to ASP.NET MVC. You get the same loose coupling and separation of concerns but the difference is in how you go about building your projects.
I have a couple of videos on my blog, source code for the framework, a sample project and a few VS.NET add-ins (New Project item, New Builder and New View).
Builder for ASP.NET
Some key differentiating Features are
1. Templates are just html - no code mixed with templates
2. Templates are thus reusable across views and Web site designers can design templates in their design tool of choice
3. Strongly typed code (no ViewData and stuff) so you get intillisense, compile time checking, F12 navigation etc.
4. You build pages as compositions of views rather than an inside-out approach
5. View can be treated as "real" classes.
6. Everything is complied so no run-time compilation
Quite a few other differentiating factors as well.
In theory :
MVC is a proved technology and yada-yada-yada, and it is ideal for websites.
But in a real case:
A serious project that use MVC required a framework, hence you are following a framework with all their limiting and restrictions. So, at this point, the specific implementation of MVC is rule and not a simple "guideline".
Also MVC fail miserably for websites when it is about to connect to the model other than simple POST/GET, it fail with xml asynchronism and it fail with ajax. (*)
(*) exist some patch but a design must be clear and functional and if you need to "patch it" then it is neither clear nor functional.
Personally i think that the main problem with MVC is that it put so much effort in the Controller, where most project use not more that 5 lines for the controller part.
ps: Most "well done" MVC projects are 3-tier project.
ps2: MVC excluding some framework, is just a buzzterm, IS NOT A SERIOUS TERMINOLOGY and it is reflexed in the group of "interpretation of mvc".

Resources