Building Web Applications with Microsoft ASP

Slides:



Advertisements
Similar presentations
Building International Applications with Visual Studio.NET Achim Ruopp International Program Manager Microsoft Corporation.
Advertisements

PHP Hypertext Preprocessor Information Systems 337 Prof. Harry Plantinga.
Building Localized Applications with Microsoft.NET Framework and Visual Studio.NET Achim Ruopp International Program Manager Microsoft Corp.
INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
Session 13 Active Server Pages (ASP) Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
IT533 Lectures Configuring, Deploying, Tracing and Error Handling.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 8: WebForms — Web-based.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Telerik Software Academy ASP.NET Web Forms Data Validation, Data Validators, Validation Groups Telerik Software Academy
Sakai: Localization & Internationalization Beth Kirschner University of Michigan
Internationalization and the Java Stack Part 1 Matt Wheeler.
ASP.NET Web API Udaiappa Ramachandran NHDN-Nashua.NET/Cloud Computing UG Lead Blog:
WEB326 ASP.NET 2.0: Going Global Gets Easier! New Localization Features in ASP.NET 2.0 Michele Leroux Bustamante Architect, IDesign Microsoft Regional.
Internationalization and the Java Stack Matt Wheeler.
The Company….  The Market Leader in Globalization Technology –Pioneers in visual translation environments –Solutions for major platforms & programming.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
OBJECTIVES  What is HTML  What tools are needed  Creating a Web drive on campus (done only once)  HTML file layout  Some HTML tags  Creating and.
Introduction to ASP.NET MVC Information for this presentation was taken from Pluralsight Building Applications with ASP.NET MVC 4.
Internationalization in the Java Stack Matt Wheeler.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
Globalization Support in Microsoft.NET Framework François Liger Program Manager Microsoft Corporation.
10 – 12 APRIL 2005 Riyadh, Saudi Arabia. Building multi-lingual ASP.Net application that handle western languages and Arabic with a single code base.
DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge.
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Google Apps (Education Edition) A step guide to a successful deployment January 10 th, 2008 California Technology Assistance Project
Localization Support in Microsoft.NET Framework François Liger Program Manager Microsoft Corporation.
Internationalization in ASP.NET 2.0. SQL Server 2005 – Data Columns Use Unicode datatypes in: Table columns, CONVERT() and CAST() operations Use Unicode.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
What’s new in ASP.NET 4.0 ?. Agenda Changes to Core Services  Extensible Output Caching  Shrinking Session State  Performance Monitoring  Permanently.
DEV392.NET Framework: Building Applications With Globalization In Mind Michele Leroux Bustamante Principal Software Architect IDesign Inc.
Creating and Editing a SEI Project Updated: May 18, 2011 – for Six Seconds’ Tools Intranet available May 30, 2011 Creating and Editing a SEI Project Updated:
Internationalization Andres Käver, IT Kolledž 2015.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC -
BIT 286: Web Applications ASP.Net MVC. Objectives Applied MVC overview Controllers Intro to Routing Views ‘Convention over configuration’ Layout files.
I18n - DateTime ASP.NET MVC. I18n DateTime – EF changes  In model classes, use attributes  DataType(DataType.DateTime)  DataType(DataType.Date)  DataType(DataType.Time)
1 Using MVC 6. MVC vs. ASP Web Forms Both run under ASP.NET Can coexist In Web Forms, browser requests page. xxx.aspx and xxx.aspx.cs on the server Page.
National College of Science & Information Technology.
Jim Fawcett CSE686 – Internet Programming Summer 2010
Jim Fawcett CSE686 – Internet Programming Spring 2014
Building Web Applications with Microsoft ASP
Building Web Applications with Microsoft ASP
Building Web Applications with Microsoft ASP
Computing with C# and the .NET Framework
Building production ready APIs with ASP.NET Core 2.0
Building Web Applications with Microsoft ASP
Building Web Applications with Microsoft ASP
Metropolia 2013 C# programming and .NET framework
ASP.Net Core Web API - Basics
Jim Fawcett CSE686 – Internet Programming Spring 2012
Building Web Applications with Microsoft ASP
Node.js Express Web Applications
Globalization support in ASP.NET
Internationalization
ASP.NET Core 2.0 Fundamentals
Building Web Applications with Microsoft ASP
Play Framework: Introduction
Dependency Injection Andres Käver, IT College 2016/2017 Spring.
Building Web Applications with Microsoft ASP
Web Applications Security What are web Applications?
MVC6. Awesomeness is here!
Anatomy of an ASP.NET Page
Developing International Applications with Visual Studio 2005
C# - EF Core IT College, Andres Käver, , Fall semester
Web API with Angular 2 Front End
Building Web Applications with Microsoft ASP
Building Web Applications with Microsoft ASP
ASP.NET MVC Web Development
C# - Razor Pages Db/Scaffolding/Async
Application Startup in ASP.NET Core
Presentation transcript:

Building Web Applications with Microsoft ASP Building Web Applications with Microsoft ASP.NET - I376 Web Application Programming II – I713 IT College, Andres Käver, 2016-2017, Spring semester Web: http://enos.Itcollege.ee/~akaver/ASP.NETCore Skype: akaver Email: akaver@itcollege.ee

ASP.NET Core – i18n Globalization (G11N): The process of making an application support different languages and regions. Localization (L10N): The process of customizing an application for a given language and region. Internationalization (I18N): Describes both globalization and localization. Culture: It is a language and, optionally, a region. Locale: A locale is the same as a culture. Neutral culture: A culture that has a specified language, but not a region. (e.g. "en", "es") Specific culture: A culture that has a specified language and region. (e.g. "en-US", "en-GB", "es-CL") https://msdn.microsoft.com/en-us/goglobal/bb896001.aspx

ASP.NET Core – i18n

ASP.NET Core – i18n - Example int value = 5600;   Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("es-CL"); Console.WriteLine(DateTime.Now.ToShortDateString()); Console.WriteLine(value.ToString("c")); Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("es-MX"); // Output 26-07-2011 // Date in es-CL, Spanish (Chile) $5.600,00 // Currency in es-CL, Spanish (Chile) 26/07/2011 // Date in es-MX, Spanish (Mexico) $5,600.00 // Currency in es-MX, Spanish (Mexico)

ASP.NET Core – i18n ASP.NET Core keeps track in each thread: Culture determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on UICulture determines which resources are loaded for the page

ASP.NET Core – i18n Set up i18n services in startup class public void ConfigureServices(IServiceCollection services) { // Add the localization services to the services container services.AddLocalization(options => options.ResourcesPath = "Resources"); // Add framework services. services.AddMvc() .AddViewLocalization(format: LanguageViewLocationExpanderFormat.Suffix) .AddDataAnnotationsLocalization();

ASP.NET Core – i18n Inject localization support into controllers public class HomeController : Controller { private readonly IStringLocalizer<HomeController> _localizer; private readonly IStringLocalizer<SharedResources> _sharedLocalizer; public HomeController( IStringLocalizer<HomeController> localizer, IStringLocalizer<SharedResources> sharedLocalizer) _localizer = localizer; _sharedLocalizer = sharedLocalizer; }

ASP.NET Core – i18n Use localization - controllers public IActionResult About() { ViewData[index: "Message"] = _localizer[name: "Here is some text to be localized!"] + " " + _sharedLocalizer[name: "Shared Info"]; return View(); }

ASP.NET Core – i18n Use localization - views @using Microsoft.AspNetCore.Mvc.Localization @using Microsoft.Extensions.Localization @inject IViewLocalizer Localizer @inject IStringLocalizer<SharedResources> SharedLocalizer @inject IHtmlLocalizer<SharedResources> SharedHtmlLocalizer @{ ViewData[index: "Title"] = "About"; } <h2>@ViewData[index: "Title"].</h2> <h3>@ViewData[index: "Message"]</h3> <p>@Localizer[name: "Use this area to provide additional information."]</p> <p>@SharedLocalizer[name: "Shared Info"]</p>

ASP.NET Core – i18n Initially localization resources are not needed – key values are used as return values. Typically localization is done later in app development lifecycle – usually by hired service (do you write Chinese?)

ASP.NET Core – i18n - resources Add new folder to web project – named “Resources” typically Specify this folder name in startup.cs Create resource files in this folder (dot or path naming) Controllers.HomeController.et.resx Views.Home.About.et.resx

ASP.NET Core – i18n How to override automatically discovered localization settings? by default, culture values are taken from current webserver settings. Add this to end of _Layout file (and add @using System.Globalization) Several possibilities how to override. Default implementation uses (middleware): QueryStringRequestCultureProvider CookieRequestCultureProvider AcceptLanguageHeaderRequestCultureProvider <p>© 2017 - WebApp @($"CurrentCulture: {CultureInfo.CurrentCulture.Name}, CurrentUICulture: {CultureInfo.CurrentUICulture.Name}")</p>

ASP.NET Core – i18n Set up the languages that are supported (ConfigureServices) services.Configure<RequestLocalizationOptions>(options =>{ var supportedCultures = new[]{ new CultureInfo(name: "en"), new CultureInfo(name: "et") }; // State what the default culture for your application is. options.DefaultRequestCulture = new RequestCulture(culture: "en-GB", uiCulture: "en-GB"); // You must explicitly state which cultures your application supports. options.SupportedCultures = supportedCultures; // These are the cultures the app supports for UI strings options.SupportedUICultures = supportedCultures; });

ASP.NET Core – i18n Set up the middleware (Configure) Test from browser url – http://…./?culture=et public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory... app.UseRequestLocalization( options: app.ApplicationServices .GetService<IOptions<RequestLocalizationOptions>>().Value);

ASP.NET Core – i18n Set up cookie mechanism – create partial and use it in _Layout @inject IViewLocalizer Localizer @inject IOptions<RequestLocalizationOptions> LocOptions @{ var requestCulture = Context.Features.Get<IRequestCultureFeature>(); var cultureItems = LocOptions.Value.SupportedUICultures .Select(c => new SelectListItem { Value = c.Name, Text = c.DisplayName }) .ToList(); } <div title="@Localizer[name: "Request culture provider:"] @requestCulture?.Provider?.GetType().Name"> <form id="selectLanguage" asp-controller="Home" asp-action="SetLanguage" asp-route-returnUrl="@Context.Request.Path" method="post" class="form-horizontal" role="form"> @Localizer[name: "Language:"] <select name="culture" onchange="this.form.submit();" asp-items="cultureItems"></select> </form> </div>

ASP.NET Core – i18n Add method to HomeController for cookie creation [HttpPost] public IActionResult SetLanguage(string culture, string returnUrl) { Response.Cookies.Append( key: CookieRequestCultureProvider.DefaultCookieName, value: CookieRequestCultureProvider.MakeCookieValue( requestCulture: new RequestCulture(culture: culture)), options: new CookieOptions { Expires = DateTimeOffset.UtcNow.AddYears(years: 1) } ); return LocalRedirect(localUrl: returnUrl); }

ASP.NET Core – i18n Todo: Save cookie based on query string Implement routing based language selection - RouteDataRequestCultureProvider

ASP.NET Core – i18n The end is near!

ASP.NET Core – i18n The end!

ASP.NET Core – i18n

ASP.NET Core – i18n

ASP.NET Core – i18n