Sitecore 6.5 with MVC3 - c#

I have to use Sitecore 6.5 with MVC framework and as per the reference document I can setup Sitecore and make that running. I have created MVC3 .NET web application project (blank and using Razor) and I dot know following things
How do I setup Layouts and Sublayouts? (this must be different then web form I guess)
What do I have to do to use Sitecore data controls e.g. FieldRenderer, Text etc. (I guess without those controls it will be not easy for us to use provide Page Editing mode)
How do I use Sitecore placeholders in MVC?
I have used this document as a reference.

At present Sitecore MVC support is setup so that ASP.NET MVC can work alongside a Sitecore installation under the same hostname.
Full support for using MVC with Sitecore will be coming in the 6.5.1 update around June time. At that point all of the things you mention plus other stuff like populating the viewbag with context data will be possible.
There are ways to achive certain parts of this integration such as a shared source module that allows Razor usage. I have personally written a small module that lets you use MVC routes with sitecore items (Sitecore MVC Routing) but for full MVC support you will have to wait until June.

Someone has made a proof of concept of the things that you want.
This blog post explains it all:
http://www.chrisvandesteeg.nl/2012/02/26/sitecore-mvc/

None of this functionality is currently easily available with MVC. Sitecore allows you to use them side-by-side, and to make some calls to the Sitecore data layer, etc., but the level of integration you (and I) are looking for has not been released yet. Supposedly coming out soon though.

Related

Some issues in my mind in Asp.net core architecture development

I started a project using Asp.net core 2.1 and read several articles on the subject.
Asp.Net Core in the new architecture, as well as the previous, while using Razor pages, as in Asp.Net also allows you to write code to behind the page.
1- I think that the best place to inject dependency to the project is the controller classes. I didn't really understand what it would be like to write to code behind of the page in the new architecture. Also, if we look at optimizing usage, we should add re-dependency behind the page. What is logic
2- When I was dealing with the project, I realized that there is no relation between the Microsoft.AspNet.Identity.EntityFramework.IdentityDbContext class and the Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext classes. If we want to upgrade any old Asp.Net project, is there any document related to architectural requirements with the reasons and best practices (as in the case of the DI mentioned above)
I don't have a problem with building the project, I'm just writing
here to document this topic in order to better understand it and not
to waste unnecessary effort.
please right click on Area > add new Scaffold item I guess if you are using VS 2017 pro+ you might get a list of pre-defined RazorPages you can add, I can say they are mostly related to Identity actions like login, register, change password, ... you can have them with minimum amount of effort on your application.
for my case if I am not going to implement a complex identity model or if I don't want to have something other than asp.net identity for my application membership the Razor Pages are the fastest way of doing that , generally, RazorPages are compared with Mvc ViewComponents (personally I don't like to use it frequently and application-wide) (i think razor pages are using MVVM pattern)
long story short, I believe that the razor pages are the fastest and the more organized way of doing some small features in a project or even doing small projects but imagine you have too many actions in a big project, then you will have tons of razor pages which will be so hard to maintain.
I can recommend that go for mvc approach and use razor pages as needed, for both cases you can still inject your class/interface either to controller constructors or Razor page constructors and still using built-in asp.net core DI (services.AddScoped, services.AddTransient, services.AddSingleton)
here is the source code for Razor pages, you can look into it if you are in the mood ;)
https://github.com/aspnet/Mvc/tree/master/src/Microsoft.AspNetCore.Mvc.RazorPages

Is it at all possible to migrate ASP.NET ASPX solution to ASP.NET Core 2.0?

I want to migrate my asp.net (UI ASPX pages WebForms) application to ASP.NET Core 2. By some search I found out aspx is not supported in .net core. If this is true(anyone has exact documentation for this?) how should anyone proceed to convert from pure asp.net aspx project to asp.net core 2.0?
I used portable analyzer tool but it is confusing to just give every .dll file and get report which is more confusing.
Please give valid Microsoft document if possible.
It all depends on what you mean by "migrate". As mentioned in the comments to your question, ASP.NET Core does not support web forms so there isn't any way to just automatically convert an a Web Forms website to an ASP.NET Core website.
That said, it is possible to make the migration. I have been working to do just that for a very large web forms based website that I want to convert to ASP.NET Core. If you are serious about making the journey, then here is some info that will probably help you.
The general architecture of ASP.NET Core is based on MVC so it's much more similar to ASP.NET MVC than ASP.NET Web Forms. So you will end up rewriting pretty much all of your UI code using some derivative of a MVC pattern. Instead of master pages you will be using layouts. Instead of server controls you will be using tag helpers. Instead of user controls you will be using partials and view components. Instead of code behinds you will be using controllers and view models. Etc.
It's worth noting that there is still an http context object, request object and response object and they are extremely similar to the analogous objects in web forms. So that helps with the conversion.
Also to make the conversion process easier, you can build an ASP.NET Core web application that targets the full framework. This means that you will have access to most everything you are use to in the full framework except anything in the System.Web namespace. Targeting the Full framework does mean that your new website will only run on windows. But if you can live with that (at least for now) it will make the conversion process easier for you.
If, in your old website, you broke out a bunch of the functionality into class libraries, that will make your life easier. You should be able to bring those class libraries over to the new website unchanged and reference them from the ASP.NET Core website and they will most likely work fine provided they don't reference System.Web. Any code that does reference System.Web will need to be modified to use the new analogous objects or UI approaches.
So in the end, you may be able to bring over your data models, data access code, business objects, and business logic without too much hassle. But you will have to do a total rewrite of your UI related code. That's the journey I'm on and it's not as hard as you might think, at least not once you get up to speed with ASP.NET Core in the first place. Go get `em!
I found an article claiming that it's possible somehow.
As you know it's not easy to migrate entire project from WebForm to .Net Core instantly. So what if I be able to have my web form pages working on production and at the same time start to convert pages one by one gradually? I mean there are the combination of two approaches at the same project.
It's the idea that an open source named DotVVM proposes. You have your ASP.Net web form pages and merely install DotVVM through Nuget. DotVVM supports both approaches. DotVVM contains similar controls like GridView, Repeater, FileUpload and more, you need to know about DotVVM syntax though.
DotVVM can run side-by-side with other ASP.NET frameworks (Web Forms, MVC, Razor Pages)
it's claimed that:
If the business layer is separated properly, rewrite on one page takes about 1 hour in average.
After a few months (if your project is large), when all the ASPX pages are rewritten in DotVVM, you will be able to create a new ASP.NET Core project, move all DotVVM pages and viewmodels into it and use them with .NET Core. The syntax of DotVVM is the same on both platforms.
Here you can see five steps needed for the migration.
You can transfer all your business logic, models and even some controller methods (You just need to adjust those ActionResult to IActionResult). If you're using Ninject (for ASP.NET Framework IOS), you just need to register them to your Startup.cs. Basically, what I'm trying to say, you need to create a new application under .NET Core. It would be changes in the actual project solution, but your actual business flow won't be different. I hope this helps you.

asp.net core 2.0 dotvvm vs razor pages - which one is more powerful for an interactive web app?

With the latest release of ASP.NET CORE version 2.0 we now have Razor Pages which I really like because it shows a MVVM way of developing which I am already familiar because I've used it in UWP.
I was searching to develop web apps without js because I am a .net developer and I came across this framework known as DOTVVM , it is great because it gives some features of js frameworks like Angular, React etc. and it also integrates very well with ASP.NET CORE 2.0
I want to discuss this between following 3 scenarios :
I should use DOTVVM and not use JS at all.
I should use Razor pages instead with asp.net core 2.0, because razor pages provide all functionality which dotvvm provides and it will have more community in future.
I should learn a JS framework like Angular or React because neither razor pages, nor dotvvm is powerful enough to replace them.
The discussion can be from point of view of all developers, so I can get opinion of JS developers as well as those who have worked with dotvvm or Razor pages. The aim is to create completely interactive and responsive web app with good performance.
**Important : ** the web app created can be a progressive web app from the start or maybe turned into a pwa after creating it, depends on the technology I choose at the end.
I know for a progressive web app I will need to write a little JS, but that is alright considering that is very simple and little to write.
The reason of this question is so that we can discuss these options from multiple perspectives and deduce a better option at the end for my app.
It really depends on the type of the application you are trying to create. The fact is that you can build any application in any web technology. The difference is only in how difficult it would be.
Razor Pages are very easy to use and they are part of ASP.NET Core platform. They are using the MVVM pattern, but they are not helping with client interactivity. If you need to hide some form field based on some condition, you would need to do it in JavaScript.
I would use them for a simple company website, very simple admin sites with few pages and trivial forms, or for a public facing part of some eCommerce site. I would probably use also jQuery or other libraries to do the interactivity, animations and things like that.
DotVVM is an MVVM framework which helps especially with web applications with complicated UI: lots of complex forms with dozens of fields and interactivity (when you select an item in a combobox, another combobox will get new values, some fields will be pre-filled, a part of the form will disappear or change and so on). Modal dialogs, multi-step wizards, lots of grids with data, sorting, paging...
Because DotVVM handles many things for you and translates the data-bindings to JavaScript, you don't need to write the JS yourself. It doesn't mean that you should not learn it. It will help you a lot if you know it - you will be able to add even more interactivity, extend the framework when you need it and more. DotVVM lets you do quite a lot without knowing JS, but you will get much further if you know it.
Angular, React or other client-side frameworks are used widely today and many websites and applications are built in that. They are more universal than DotVVM, which aims primarily at the business app segment and requires .NET on the server (because it is not only the client-side library).
Using Angular or React requires the knowledge of JavaScript, and not only that. You will need to know Node.js and the related tooling, like npm. You will need to exchange data with the server, so you will need to build probably a REST API, use Swagger to generate the client-side proxy classes, and then you will probably need some other JS libraries with controls and things like that.
It is quite a lot of things to learn and if you are used to the comfort of Visual Studio, like the IntelliSense or the debugger, you will miss these features for sure.
And finally, you don't need to stick to one technology. You can combine Razor Pages with DotVVM for example. You can make the admin dashboard in DotVVM and the public part of the website in Razor Pages.
Microsoft is coming back to the WebForms approach to simplify the project structure trusting in the "Convention over configuration" mantra, while hiding the configuration from developer to make things faster. But it has the disavantage that everything will be mixed again. I doesn't look like a smart move for organizing. But... Hey! Something new must catch the attention of the dev towards Microsoft.
If your page uses an MVC Web API for the REStful, it's really more easy to just use Razor pages. If not, I would recommend you to use Core MVC.

How to add Angular 2.0 to an existing ASP.NET MVC app

I have a very large asp.net MVC 4.0 application that I'd like to start migrating to Web API with asp.net 5.0 and Angular 2.0.
The main reason is to start future proofing and setting up some new components into a more modern SPA architecture.
My plan is to have a small section of the existing site which when routed to displays an Angular SPA app calling Web API for data, instead of the MVC controller and functions. For this section, I'm not planning on using ASP.NET MVC features such as the shared layout page, bundling, routing etc, preferring to instead leave this to angular.
Both my existing MVC and new Web api projects will be using the data layer project/repository which uses EF.
My questions are:
How does this sound? I couldn't find much literature on how to introduce angular into an existing app
Should I use separate projects, or a whole separate solution on a new domain which accesses the same db? Ie, rather than migrate, start a new solution on ASP.NET 5.0
How to I handles authentication and authorisation? I'm using Identity v2.0, can I mix that so that users accessing pages on the MVC site use standard forms based authentication, but when accessing the Angular/ API portion they use tokens?
Thanks for your time.
We've been in this process for last 6 months (the only difference is Angular, rather than Angular 2). And here is my opinion...
a small section of the existing site which when routed to displays an Angular SPA app calling Web API for data, instead of the MVC controller and functions
Extremely difficult, if not impossible, since ASP.NET Core is fundamentally very different from MVC 4. I would suggest to have a separate site (on a different port) that runs Core and Angular.
I'm not planning on using ASP.NET MVC features such as the shared layout page, bundling, routing etc, preferring to instead leave this to angular.
That was our first approach, but in order to accomplish it, we would need to pre-load a lot of Javascript libraries, or do smart things for dynamic loading. It is easier in Angular2 (SystemJS that allows dynamic loading is built into the infrastructure). Instead, we split the application into about half-dozen features. Each feature has a .NET controller and a single view (Index.cshtml). Within the feature we use Angular capabilities for routing, views, etc. This approach also helped us to have strongly typed views.
Should I use separate projects, or a whole separate solution on a new domain which accesses the same db?
Entity Framework is also quite different. In our old (very old) solution we didn't use EF at all, so it was an easier decision. But even if you do use EF in current solution, EF Core is also a different animal, including the way it does migrations. It was much easier for us to have a clean cut.
How to I handles authentication and authorisation?
Our old system was using membership framework, and we didn't have anybody on the team familiar with OAuth. So, while waiting for IdentityServer 4 (that currently has almost no documentation), I suggest you consider SaaS solutions like StormPath or Auth0 (we love StormPath). If you have experience with IdentityServer, you may jump into IdentityServer 4. Since we are using MVC, our authentication is very straightforward; but I think AJAX-based authentication wouldn't be that much more difficult.
Hope that helps. SO doesn't like "opinion-based" questions - but I think there are a lot of teams struggling with this type of transition, and hopefully, this question and answer are appropriate :)

Advertisement upload admin module implementation using AdSence

I want to make available the UI for my site administrator to upload the advertisements for the site. I just come across the Google adsence concept for the same. so can i build this using adsence API and how ? I mean i need the sample P O C so that move a head with considerations. i am new in adsence totally. i didn't heard about it so far. so want to understand its capabilities also.
Considering you have multiple pages to display the same data, so potentially different Views, you can take into account MVP / MVC patterns. So main purpose is to separate View from undelying logic and data itself.
Also take a look at the ASP.NET MVC, perhaps you can build your web application using this framework.
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic
websites that enables a clean separation of concerns and that gives
you full control over markup for enjoyable, agile development. ASP.NET
MVC includes many features that enable fast, TDD-friendly development
for creating sophisticated applications that use the latest web
standards

Categories

Resources