How do I use JavaScriptSerializer in ASP.NET 5? - asp.net-core

I am porting my project to DNX-Core 5.0 and trying to get work but I cannot find the JavaScriptSerializer and AppSettingReader classes. I know the System.Web is removed and so please anyone help me to find the alternative of using them.
Is there any Nuget available to include them?

The ASP.Net 5 team dropped the JavaScriptSerializer in favor of the widely used Newtonsoft.Json package, but they did provide a JsonOutputFormatter and a JsonInputFormatter for use with MVC to be able to return objects more directly.
For the AppSettingReader you'll want to look at the new ASP.Net 5 Configuration Model. This has been detailed in a few blog posts while it's being built. These posts only detail how to load out individual fields, but the tests in the Options Model show that you can bind directly to an object.

Related

how to convert yii 1 application to version 2

We have website which built in yii 1.1 version, now we would like to convert it to version 2. But we already have a lots of functionality and we do not have much time to do everything by scratch in yii 2. please do suggest.
I don't think there is a fast way of converting or migrating from Yii 1.1 to Yii2. They are similar in some ways but different enough.
I would recommend you first read most of The Definitive Guide to Yii 2.0, which includes Upgrading from Version 1.1.
In my opinion the best you can do is try to replicate the same modules and their functionality one at a time, trying to reuse as much code as you can from the 1.1 version. A few things that i think would be important are:
Create the new Yii2 models using Gii and adapt methods from your Yii 1.1 models. Edit and add validation rules as needed. There are many rules that might not have been available in Yii 1.1, however it can also be true the other way around.
Generate Yii2 modules with Gii. Just need these to create a better project structure. If you didn't use modules on Yii 1.1 i would recommend doing so for Yii2.
Generate Yii2 CRUDs with Gii inside the corresponding modules. This will help generate the controller, actions, views and search model needed for basic CRUD functionality. After that, you will need to edit the views and controller to fit your needs, which you can use your 1.1 code for reference.
Install needed extensions and widgets using composer. Many extensions from Yii 1.1 have updated versions for Yii2, but for those that do not you will have to find substitutes, which shouldn't be too difficult, although you will most likely have to read the documentation for both familiar and new extensions.
In the end you will need to spend time to have a Yii2 version of your website, there is no easy and fast way to jump
You don't need to convert your application completely you can use both at same time please have a look to
http://www.yiiframework.com/doc-2.0/guide-tutorial-yii-integration.html

which dll or namespace of ASP.net 4 (MVC5) should not be present in ASP.5 (MVC6) after migration

Hi I understood from post available at below link
http://docs.asp.net/en/latest/conceptual-overview/aspnet.html
http://weblogs.asp.net/scottgu/introducing-asp-net-5
that ASP.Net 5 no longer required to have system.web.dll, what are the other namespace it should not have.
My MVC 5 project references system.web.extension.dll perticulary JavaScriptSerializer Class, i am not sure if should be using that or if there is any other alternative to it.
there are other namespaces also start with system.web as below should that also be avoided
using System.Web.Http;
using System.Web.Http.ModelBinding;
using System.Web.OData;
using System.Web.OData.Routing;
is it that only system.web.dll should not be used in ASP.net 5 MVC 6 project.
I believe anything beginning system.web.* shouldn't be there and has been replaced with something within Microsoft.AspNet.
I'm not sure how you are planning on doing the migration but the article Migrating From ASP.NET MVC 5 to MVC 6 on docs.asp.net covers the process pretty well.
Essentially it advises starting with a blank MVC 6 / Asp.Net.Core 1 (the new name for Asp.Net 5) project and porting the content over.
That way you can lean on the compiler to tell you things that aren't available. A lot of what can / can't will depend on wether its Framework 4.6 or .NET Core 1.0 (prevously .NET Core 5).
As for JavaScriptSerializer I believe the recomended alternative is Newtonsoft.Json.
Depending what you use it for there is also now JsonOutputFormatter and JsonInputFormatter
I haven't been through the full process yet, but I strongly suspect moving to Framework 4.6 will be the easier destination :-)

asp.net mvc 4 localization resource path too long

I've created a class library in which I store my resource files for my asp.net mvc4 localization. I've been following the same folder structure as my Views.
I'm ending up having to reference strings such as:
#Resource.QuoteArea.Quote.Auto.DriverInfo
That is very long and tedious to type. Plus it makes my Views hard to read. Is there a better (neater) way for doing localization in mvc 4 ? Perhaps using a third-party library ? I already use mvccontrib for my model localization, so that's sorted. However for non-model related things, I'm facing the aforementioned issue.
You can change the resource namespace in the resource properties, to make it shorter. This blog post was very helpful for me, and will be for you to.
http://adamyan.blogspot.co.uk/2010/02/aspnet-mvc-2-localization-complete.html

Which namespace should I use for my Asp.NET MVC 4 beta Filters?

I am trying to implement a global exception handler in Asp.NET MVC 4 beta. As I understand it I am supposed to implement an IExceptionFilter and add that to the filters collection. However I was unable to make it work when using the System.Web.Mvc.IExceptionFilter. Am I supposed to use that one, or is the System.Web.Http.Filters.IExceptionFilter (and related classes) the ones I should be using?
Asking another way:
Should I be adding filters to the GlobalConfiguration.Configuration.Filters or GlobalFilters.Filters?
System.Web.Http namespace completely belongs to ASP.NET Web API framework, not ASP.NET MVC.
As for the registration point, you need to add them into GlobalFilters.Filters collection.
So after getting some pointers from #tugberk, I realize my mistake. I was basically asking for the wrong thing. What I wanted was to be able to add filters for an ASP.NET Web API service, not add them for an mvc application.
I made this error thinking they were one and the same. I guess I must have read som of what was said about moving these things together the wrong way.
In any case. I should be using the System.Web.Http namespace for my case, which means adding to the GlobalConfiguration.Configuration.Filters collection.
I found a rather nice weblog showing a basic implementation of some of what I want to accomplish. Maybe it can help somebody else.

.Net 4.0, New methods in existing classes

Is there a blog or MSDN article, which lists all the new methods which are added in .Net 4.0 in existing classes? I could not find any.
Two which I found on blogs till now:
String.IsNullOrWhiteSpace
Enum.HasFlag
Are there more such methods added which anybody found? If yes, please share.
On the blog of the .NET BCL (base class library) team, there is a list of changes, although it is for .NET 4 Beta 1 and 2:
http://blogs.msdn.com/bclteam/archive/2009/05/22/what-s-new-in-the-bcl-in-net-4-beta-1-justin-van-patten.aspx
http://blogs.msdn.com/bclteam/archive/2009/10/21/what-s-new-in-the-bcl-in-net-4-beta-2-justin-van-patten.aspx
Theres a few new ones on the page class:
Page.MetaDescription = "";
Page.MetaKeywords = "";
Plus a new 301 method:
Response.RedirectPermanent("~/page.aspx");
I guess this isn't really the best way to approach it as many of the new features wouldn't make much sense without being put into context.
This document highlights most of the new features if you want to get up to speed on .net 4:
ASP.NET 4 and Visual Studio 2010 Web Development Overview
This link shows the updated list, which gammelgul posted, for RTM:
http://msdn.microsoft.com/en-us/library/ms171868(v=VS.100).aspx