Tag Archives: learn asp.net

FOR MVC DEVELOPERS THE FEATURES OF ASP.NET CORE

ASP.NET Core 1.0 gives a patched up Web development system adapted towards the prerequisites of present day Web applications. The new structure, as of now in RC1, obliges you to learn numerous new ideas not found in ASP.NET MVC 5. To that end, this article identifies a couple of essential components that ASP.NET MVC 5 designers ought to know as they get ready to take in this new structure.

1. ASP.NET Core on Numerous Runways

ASP.NET Core is a piece of .NET Core—another measured structure that backings numerous stages.ASP.NET and the .NET framework are focused on towards the Windows stage. Then again, ASP.NET Core is created to bolster various stages including Windows, Mac, and Linux. This additionally implies, dissimilar to ASP.NET web applications, basically, keep running under IIS, the ASP.NET Core applications can keep running under non-IIS Web servers.

ASP.NET CORE 1.0

Figure 1 demonstrates the part of the .NET Core and ASP.NET Core.

The part of the .NET Core and ASP.NET Core -

A Web application worked with ASP.NET Core can target ASP.NET Framework 4.6 or the ASP.NET Core. The Web applications focusing on ASP.NET Framework 4.6 run just on the Windows stage. The Web applications focusing on the ASP.NET Core can keep running on Windows and non-Windows stages. Obviously, as on this composition, ASP.NET Core doesn’t offer the same rich usefulness offered by ASP.NET Framework 4.6.

2. Part of Project.json

ASP.NET Core utilizes an exceptional document—Project.json for putting away all the undertaking level configuration data. Project.config can store numerous design settings, for example, references to NuGet bundles utilized as a part of the task and target structures.

“dependencies”: {
“Microsoft.AspNet.IISPlatformHandler”: “1.0.0-rc1-final”,
“Microsoft.AspNet.Server.Kestrel”: “1.0.0-rc1-final”,
“Microsoft.AspNet.Mvc”: “6.0.0-rc1-final”,
“Microsoft.AspNet.Mvc.TagHelpers”: “6.0.0-rc1-final”,
“Microsoft.AspNet.StaticFiles”: “1.0.0-rc1-final”,
“Microsoft.AspNet.Tooling.Razor”: “1.0.0-rc1-final”,
“Microsoft.Extensions.Configuration.Abstractions”:
“1.0.0-rc1-final”,
“Microsoft.Extensions.Configuration.Json”:
“1.0.0-rc1-final”,
“EntityFramework.MicrosoftSqlServer”: “7.0.0-rc1-final”,
“EntityFramework.Commands”: “7.0.0-rc1-final”,
“Microsoft.AspNet.Session”: “1.0.0-rc1-final”,
“Newtonsoft.Json”: “8.0.3”

The Project.json record stores configuration data in JSON position. The above markup demonstrates a conditions segment that contains a rundown of NuGet bundles required by the application. For instance, the Web application under thought requires the 6.0.0-rc1-last form of Microsoft.AspNet.Mvc get together, etc

3. Part of AppSettings.json

ASP.NET stores application configuration settings in Web.config. For instance, engineers utilize the <appSettings> area to store custom application settings, the <connectionStrings> segment to store database association strings, etc. ASP.NET Core utilizes AppSettings.json to store such bits of data.

Consider the accompanying configuration:

{
“AppSettings”: {
“Title”: “My ASP.NET Core Application”
},

“Data”: {
“DefaultConnection”: {
“ConnectionString”: “data source=.;
initial catalog=Northwind;integrated security=true”
}
}
}

The previous JSON markup comprises of two properties or keys, to be specific AppSettings and Data. The AppSettings property holds a sub-key named Title. The Title sub-key has a string estimation of “My ASP.NET Core Application”. Also, the Data key has a DefaultConnection sub-key. The DefaultConnection thusly has a ConnectionString sub-key.

4. Application set-up

In ASP.NET, Global.asax goes about as the passage point for your application. You can wire different events handlers for occasions, for example, Application_Start and Session_Start, in the Global.asax record. In ASP.NET Core, the application startup happens in an unexpected way—it happens through a Startup class.

one such Startup class -

public class Startup
{
public Startup(IHostingEnvironment env,
IApplicationEnvironment app)
{
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.SetBasePath(app.ApplicationBasePath);
builder.AddJsonFile(“appsettings.json”);
IConfigurationRoot config = builder.Build();
string str = config.Get<string>
(“Data:DefaultConnection:ConnectionString”);
// do something with str
}

public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddEntityFramework()
.AddSqlServer();
}

public void Configure(IApplicationBuilder app)
{
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: “default”,
template: “{controller=Home}/
{action=Index}/{id?}”);
});
}

public static void Main(string[] args) =>
WebApplication.Run<Startup>(args);
}

The Startup class appeared above starts with a constructor. The constructor stacks the AppSettings.json record utilizing ConfigurationBuilder class. The Get() strategy then is utilized to peruse the database association string put away in the AppSettings.json document.

The ConfigureServices() technique includes the administrations required by the application. For instance, here you add MVC and Entity Framework to the administrations gathering.

The Configure() technique determines and arranges the administrations included before for application’s utilization. For instance, the MVC directing is designed in the code appeared previously.

5. Tag Helpers

In ASP.NET MVC 5, you utilized HTML assistants, for example, BeginForm(), LabelFor(), and TextBoxFor() to render structures and frame fields. You can keep on using HTML partners in ASP.NET Core, too. However, there is a superior option: Tag Helpers. Label aides take the type of standard HTML labels with certain extraordinary asp-* credits added to them.

Consider the accompanying markup that renders a structure:
<form asp-controller=”Home” asp-action=”Save” method=”post”>
<table border=”1″ cellpadding=”10″>
<tr>
<td><label asp-for=”FirstName”>First Name :</label></td>
<td><input type=”text” asp-for=”FirstName” /></td>
</tr>
<tr>
<td><label asp-for=”LastName”>Last Name :</label></td>
<td><input type=”text” asp-for=”LastName” /></td>
</tr>
<tr>
<td><label asp-for=”Email”>Email :</label></td>
<td><input type=”text” asp-for=”Email” /></td>
</tr>
<tr>
<td><label asp-for=”Phone”>Phone :</label></td>
<td><input type=”text” asp-for=”Phone” /></td>
</tr>
<tr>
<td colspan=”2″>
<input type=”submit” value=”Submit” />
</td>
</tr>
</table>
</form>

Observe clearly, the properties that start with asp-. They are characterized by the label aides. For instance, the structure label aide utilizes asp-controller ascribe to indicate the objective controller name and asp-activity credit to determine the objective activity technique name. Correspondingly, asp-for traits utilized with name and info label partners tie a name or a text box to a model property. Label partners are more advantageous to use than HTML assistants in light of the fact that their linguistic structure nearly takes after the HTML markup.

6. View Components

In MVC 5, you utilized halfway perspectives as a way to reuse markup and code. ASP.NET Core presents View Components, the more intense and adaptable option. A perspective part comprises of a class normally acquired from ViewComponent base class and a perspective record containing the required markup. This programming model is entirely like the one utilized by controllers and perspectives. It permits you to separate code and markup from each other—code in the perspective segment class and markup in a perspective. Once made, you can utilize a perspective segment on a perspective by utilizing the @Component.Invoke() technique.

7. Dependency Injection

ASP.NET Core gives an inbuilt reliance infusion system. The DI system of ASP.NET Core offers four-lifetime modes for a sort being infused:
Singleton: An object of an administration (the sort to be infused) is made and supplied to all the requests to that administration. Along these lines, fundamentally all requests get the same article to work with.

Scoped: An object of an administration is made for every single request. In this way, every request gets another event of an administration to work with.

Transient: An object of an administration is made each time an article is asked.

Instance: For this situation, you are in charge of making an object of an administration. The DI system then uses that case in singleton mode said prior

public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSingleton<IMyService,MyService>();
}

Here, MyService is the sort to be enlisted with the DI structure and actualizes IMyService. The AddSingleton() technique enlists this type for Singleton mode portrayed previously. Once a sort is enrolled with the DI system, you can infuse it in a controller like this:

public class HomeController : Controller
{
private IMyService obj;

public HomeController(IMyService obj)
{
this.obj = obj;
}
….
….
}

8. Gulp, Grunt, and Bower Support

Gulp and Grunt are JavaScript assignment runners. They help you computerize generally required undertakings, for example, packaging JavaScript and CSS records, minifying JavaScript and CSS documents, and arranging Less and Sass records (and some more). They are introduced utilizing npm (Node Package Manager). The ASP.NET Core venture made utilizing Visual Studio 2015 permits you to include Grunt and Gulp arrangement documents furthermore gives Task Runner Explorer to screen the errands.

Bower is a bundle administrator basically for front-end bundles. Front-end bundles are the bundles that you use in your Web pages, for example, JavaScript libraries/systems and CSS records. For instance, you may introduce jQuery in your ASP.NET Core venture by utilizing Bower. An ASP.NET Core venture made utilizing Visual Studio 2015 permits you to include a Bower setup document. You likewise can work with the bundles utilizing the Manage Bower Packages menu choice.

9. Single Programming for Web API Model for and MVC

In MVC 5, controllers acquire from the System.Web.Mvc.Controller base class. What’s more, Web API 2 controllers acquire from System.Web.Http.ApiController. In ASP.NET Core, both of these structures are converged into a solitary system. Therefore, under ASP.NET Core, an MVC controller and Web API controller both acquire from Microsoft.AspNet.Mvc.Controller base class. You then can design viewpoints, for example, HTTP verb mapping and the directing of the controllers as coveted.

10. Static Files and the wwwroot Folder

In ASP.NET, there is no settled area for putting away static documents, for example, picture records, JavaScript documents, and CSS records (engineers regularly utilized a Content envelope to store such documents). In ASP.NET Core, all the static records are kept under the wwwroot envelope (default). You likewise can change the name of this envelope by utilizing the Project.json document.

Refer the figure following down -

After arrangement, the wwwroot turns into the Web application’s root. Every one of the URLs to static records are determined as for this envelope. Along these lines,/pictures/logo.png anticipates that logo.png will be available under the wwwroot/pictures envelope.

Conclusion -

ASP.NET Core 1.0 is a redone system outfitted towards present day cloud based, measured Web applications. Despite the fact that the new structure safeguards the key ideas of MVC 5, ASP.NET engineers will discover numerous contrasts between MVC 5 and ASP.NET Core 1.0. This article specified the imperative new components/ideas that you have to comprehend to start your voyage with ASP.NET Core 1.0.

We the institute provide training in dot net field to freshers to know the reviews about our company visit crb tech reviews.

Related Articles:

8 Killer Techniques To Learn .NET

Top 5 Reasons That Make ASP.NET More Secure Over PHP

Don't be shellfish...Buffer this pageEmail this to someoneDigg thisShare on FacebookShare on Google+Share on LinkedInPrint this pageShare on RedditPin on PinterestShare on StumbleUponTweet about this on TwitterShare on Tumblr

PHP VS ASP.NET

PHP is surely a standout amongst the most well-known scripting languages for web developers working over the globe, hence taking the scene of PHP programming in India and abroad to a genuine high. Fairly comparable has been the scene for ASP.NET that serves as a helpful tool for designers in building web applications. Both of these programming languages are utilized as a part of making substantial web applications and easy to complex locales thus neither of them can be said to be unfeasible and less-effective. However, there are a couple of contrasts that may give PHP an edge over ASP.NET or the other way around.

A Brief Overview of PHP and ASP.NET

PHP signifies Hypertext Pre – processor. It’s a scripting device that has immediately picked up unmistakable quality attribution’s to it’s not an insignificant rundown of promising components. More than 244 million sites as of now have PHP introduced at present. WordPress and PHP are a portion of the well-known destinations manufactured utilizing PHP. It is sponsored by a huge designer group that works day and night to make it more intentional for clients. Being open source truly indicates the brighter side of this adaptable programming dialect.

As a successor to ASP (Active Server Pages), ASP.NET is created by Microsoft. As a simple-to-use scripting device,NET serves as a valuable system in the hands of developers. A standout amongst a huge angle identifies with the utilization of any .NET upheld language for coding. It is likewise one reason why ASP.NET is most loved among developers. In addition to that, Microsoft’s control of web program business sector and you regard the comprehensive value of this Microsoft created language. Observe the pattern of these two prominent programming languages.

PHP versus ASP.NET – Scalability and Performance insightful Comparison

Despite the fact that PHP and ASP.NET bring a considerable measure of improvement cordial components; there are some purposes of correlations where these come with no holds barred. For an instance, consider the versatility viewpoint; both of these programming languages are profoundly adaptable however the degree of adaptability relies on the abilities of engineers to scale their application adequately. It’s surely understood that versatility primarily relies upon the software developers experience, faithfulness to programming rules and guidelines and so on. In this way, both of these rise out as equivalent champs in this circle.

Additionally, quite a bit of open deliberation has been rotating around the execution of these magnificent programming languages. Web application speed estimation relies on a few components that ought to be essentially having no impact on the pace and execution of sites. Also, the performance of web applications is an element of server, database and script. PHP based web applications take after the LAMP stack that has been widely improved for better execution.

An exceptionally minor distinction exists between a PHP+MySQL stack and ASP.NET+MSSQL stack, However, PHP+MySQL is developing out as a victor. Likewise, there is a decent risk that a PHP web application running on Linux host will beat a comparable ASP.NET application running on Windows host.

Related Articles:

Top 5 Reasons That Make ASP.NET More Secure Over PHP

Bringing PHP to .Net is the Aim of Peachpie

Don't be shellfish...Buffer this pageEmail this to someoneDigg thisShare on FacebookShare on Google+Share on LinkedInPrint this pageShare on RedditPin on PinterestShare on StumbleUponTweet about this on TwitterShare on Tumblr