Register here: http://gg.gg/wa678
Re: how to make a login/password authentication in asp.net mobile ?
Aug 16, 2007 01:33 PM|slavik118|LINK
Affiliate marketing program for the gaming industry. © 2004 - 2021 Affiliate Software powered by Income Access, a Paysafe company.
Creating of a login/password authentification in asp.net mobile is in many ways similar to web. Try script below:
*Top Up Vouchers.
*Hollywoodbets Free Listening on SoundCloud. Help your audience discover your sounds. Let your audience know what to hear first. With any Pro plan, get Spotlight to showcase the best of your music & audio at the top of your profile. Learn more about Pro.
using System.Configuration;
using System.Data.SqlClient;
using System.Web.Security;
protectedvoid Page_Load(object sender, EventArgs e) {// Assign properties to SelectionList mobile control
chkPersist.Items.Add(’Click here to save Login Session’);
chkPersist.Items[0].Value = ’save’;
}publicstaticint LoginUser(string username, string password) {
// Create Instance of your site Connection and Command Object
// You need to define Connection object in the web.config file SqlConnection conPortal = newSqlConnection(ConfigurationManager.ConnectionStrings[’Portal’].ConnectionString);
SqlCommand cmdLoginUser = newSqlCommand(’Portal_LoginUser’, conPortal);
// Mark the Command as a SPROC
cmdLoginUser.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC
cmdLoginUser.Parameters.Add(’@RETURN_VALUE’, SqlDbType.Int).Direction = ParameterDirection.ReturnValue;
cmdLoginUser.Parameters.Add(’@username’, username);
cmdLoginUser.Parameters.Add(’@password’, password);
// Execute the command
conPortal.Open();
cmdLoginUser.ExecuteNonQuery();
int retVal = (int)(cmdLoginUser.Parameters[’@RETURN_VALUE’].Value);
conPortal.Close(); return retVal;
}
protectedvoid cmdLogin_Click(object sender, EventArgs e) {Hollywoodbets Net Mobile bool blPersist = false;
// Determine whether password should be persisted
if (chkPersist != null)
blPersist = chkPersist.Items[0].Selected; // Either login or display error message
switch (LoginUser(txtUsername.Text, txtPassword.Text)) {
case 0: // Success!
FormsAuthentication.SetAuthCookie(txtUsername.Text, blPersist);
string redirectUrl = FormsAuthentication.GetRedirectUrl(txtUsername.Text, blPersist).ToLower();
if (redirectUrl.IndexOf(’users_logout.aspx’) -1) {
if (Context.Request.QueryString[’_lang’] != null) {
Context.Response.Redirect(redirectUrl);
}
else {
Context.Response.Redirect(redirectUrl);
}
}
else {
if (Context.Request.QueryString[’_lang’] != null) {
Context.Response.Redirect(’default.aspx?_lang=’ + Context.Request.QueryString[’_lang’].ToString());
}
else {
Context.Response.Redirect(’default.aspx?_lang=en’);
}
}
break;
case 1: // Invalid Password
pnlInvalidPassword.Visible = true;
pnlInvalidUsername.Visible = false;
break;
case 2: // Invalid Username
pnlInvalidUsername.Visible = true;
pnlInvalidPassword.Visible = false;
break;
}
}
Add the following line to the Web.Config file:<connectionStrings>
<addname=’Portal’connectionString=’Data Source=.SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|MobileDB.mdf’ providerName=’System.Data.SqlClient’/> </connectionStrings>

Create Portal_LoginUser SPOC in your database: CREATE PROCEDUDE [dbo].[Portal_LoginUser]
(
@username NVarchar( 50 ),
@password NVarchar( 50 )
)
AS
if exists
(
SELECT UserName
FROM Portal_Users
WHERE UserName = @username
AND UserPassword = @userpassword
)
RETURN 0 -- Success
if exists
(
SELECT UserName
FROM Portal_Users
WHERE UserName = @username
)
RETURN 1 -- Wrong username
RETURN 2 -- Wrong password
Add the following web controls to the mobile web form

<mobile:Formid=’frmLogin’runat=’server’Title=’Login’>Please enter your name and password below. <br/>
<mobile:PanelID=’pnlInvalidUsername’Runat=’server’Visible=’False’>Username you entered is invalid!</mobile:Panel>
<mobile:PanelID=’pnlInvalidPassword’Runat=’server’Visible=’False’>The password you entered is invalid!</mobile:Panel>
User Name:&nbsp;<mobile:TextBoxID=’txtUsername’Runat=’server’></mobile:TextBox>
Password:&nbsp;&nbsp;<mobile:TextBoxID=’txtPassword’Runat=’server’Password=’True’></mobile:TextBox>
<mobile:SelectionListID=’chkPersist’Runat=’server’SelectType=’CheckBox’ Title=’Save Session ’></mobile:SelectionList>&nbsp;
<mobile:Command ID=’cmdLogin’Runat=’server’OnClick=’cmdLogin_Click’>Login</mobile:Command></mobile:Form>
Good luck! -->
Applies To
*ASP.NET Web Forms version 4.0
*ASP.NET MVC version 3.0
Summary
This How To describes various ways to serve pages optimized for mobile devices from your ASP.NET Web Forms / MVC application, and suggests architectural and design issues to consider when targeting a broad range of devices. This document also explains why the ASP.NET Mobile Controls from ASP.NET 2.0 to 3.5 are now obsolete, and discusses some modern alternatives.Contents
*Overview
*Architectural options
*Browser and device detection
*How ASP.NET Web Forms applications can present mobile-specific pages
*How ASP.NET MVC applications can present mobile-specific pages
*Additional resources
For downloadable code samples demonstrating this white paper’s techniques for both ASP.NET Web Forms and MVC, see Mobile Apps & Sites with ASP.NET.Overview
Mobile devices – smartphones, feature phones, and tablets – continue to grow in popularity as a means to access the Web. For many web developers and web-oriented businesses, this means it’s increasingly important to provide a great browsing experience for visitors using those devices.How earlier versions of ASP.NET supported mobile browsers
ASP.NET versions 2.0 to 3.5 included ASP.NET Mobile Controls: a set of server controls for mobile devices in the System.Web.Mobile.dll assembly and the System.Web.UI.MobileControls namespace. The assembly is still included in ASP.NET 4, but it is deprecated. Developers are advised to migrate to more modern approaches, such as those described in this paper.
The reason why ASP.NET Mobile Controls have been marked as obsolete is that their design is oriented around the mobile phones that were common around 2005 and earlier. The controls are mainly designed to render WML or cHTML markup (instead of regular HTML) for the WAP browsers of that era. But WAP, WML, and cHTML are no longer relevant for most projects, because HTML has now become the ubiquitous markup language for mobile and desktop browsers alike.The challenges of supporting mobile devices today
Even though mobile browsers now almost universally support HTML, you will still face many challenges when aiming to create great mobile browsing experiences:
*Screen size - Mobile devices vary dramatically in form, and their screens are often much smaller than desktop monitors. So, you may need to design completely different page layouts for them.
*Input methods – Some devices have keypads, some have styluses, others use touch. You may need to consider multiple navigation mechanisms and data input methods.
*Standards compliance – Many mobile browsers do not support the latest HTML, CSS, or JavaScript standards.
*Bandwidth – Cellular data network performance varies wildly, and some end users are on tariffs that charge by the megabyte.
There’s no one-size-fits-all solution; your application will have to look and behave differently according to the device accessing it. Depending on what level of mobile support you want, this can be a bigger challenge for web developers than the desktop ’browser wars’ ever was.
Developers approaching mobile browser support for the first time often initially think it’s only important to support the latest and most sophisticated smartphones (e.g., Windows Phone 7, iPhone, or Android), perhaps because developers often personally own such devices. However, cheaper phones are still extremely popular, and their owners do use them to browse the web – especially in countries where mobile phones are easier to get than a broadband connection. Your business will need to decide what range of devices to support by considering its likely customers. If you’re building an online brochure for a luxury health spa, you might make a business decision only to target advanced smartphones, whereas if you’re creating a ticket booking system for a cinema, you probably need to account for visitors with less powerful feature phones.Architectural options
Before we get to the specific technical details of ASP.NET Web Forms or MVC, note that web developers in general have three main possible options for supporting mobile browsers:
*
Do nothing – You can simply create a standard, desktop-oriented web application, and rely on mobile browsers to render it acceptably.
*
Advantage: It’s the cheapest option to implement and maintain – no extra work
*
Disadvantage: Gives the worst end-user experience:
*The latest smartphones may render your HTML just as well as a desktop browser, but users will still be forced to zoom and scroll horizontally and vertically to consume your content on a small screen. This is far from optimal.
*Older devices and feature phones may fail to render your markup in a satisfactory way.
*Even on the latest tablet devices (whose screens can be as big as laptop screens), different interaction rules apply. Touch-based input works best with larger buttons and links spread further apart, and there’s no way to hover a mouse cursor over a fly-out menu.
*
Solve the problem on the client – With careful use of CSS and progressive enhancement you can create markup, styles, and scripts that adapt to whatever browser is running them. For example, with CSS 3 media queries, you could create a multi-column layout that turns into a single column layout on devices whose screens are narrower than a chosen threshold.
*Advantage: Optimizes rendering for the specific device in use, even for unknown future devices according to whatever screen and input characteristics they have
*Advantage: Easily lets you share server-side logic across all device types – minimal duplication of code or effort
*Disadvantage: Mobile devices are so different from desktop devices that you may really want your mobile pages to be completely different from your desktop pages, showing different information. Such variations can be inefficient or impossible to achieve robustly through CSS alone, especially considering how inconsistently older devices interpret CSS rules. This is particularly true of CSS 3 attributes.
*Disadvantage: Provides no support for varying server-side logic and workflows for different devices. You can’t, for example, implement a simplified shopping cart checkout workflow for mobile users by means of CSS alone.
*Disadvantage: Inefficient bandwidth use. You server may have to transmit the markup and styles that apply to all possible devices, even though the target device will only use a subset of that information.
*
Solve the problem on the server – If your server knows what device is accessing it – or at least the characteristics of that device, such as its screen size and input method, and whether it’s a mobile device – it can run different logic and output different HTML markup.
*Advantage: Maximum flexibility. There’s no limit to how much you can vary your server-side logic for mobiles or optimize your markup for the desired, device-specific layout.
*Advantage: Efficient bandwidth use. You only need to transmit the markup and styling information that the target device is going to use.
*Disadvantage: Sometimes forces repetition of effort or code (e.g., making you create similar but slightly different copies of your Web Forms pages or MVC views). Where possible you will factor out common logic into an underlying layer or service, but still, some parts of your UI code or markup may have to be duplicated and then maintained in parallel.
*Disadvantage: Device detection is not trivial. It requires a list or database of known device types and their characteristics (which may not always be perfectly up-to-date) and isn’t guaranteed to accurately match every incoming request. This document describes some options and their pitfalls later.
To get the best results, most developers find they need to combine options (2) and (3). Minor stylistic differences are best accommodated on the client using CSS or even JavaScript, whereas major differences in data, workflow, or markup are most effectively implemented in server-side code.This paper focuses on server-side techniques
Since ASP.NET Web Forms and MVC are both primarily server-side technologies, this white paper will focus on server-side techniques that let you produce different markup and logic for mobile browsers. Of course, you can also combine this with any client-side technique (e.g., CSS 3 media queries, progressive-enhancement JavaScript), but that’s more a matter of web design than ASP.NET development.Browser and device detection
The key prerequisite for all server-side techniques for supporting mobile devices is to know what device your visitor is using. In fact, even better than knowing the manufacturer and model number of that device is knowing the characteristics of the device. Characteristics may include:
*Is it a mobile device?
*Input method (mouse/keyboard, touch, keypad, joystick, …)
*Screen size (physically and in pixels)
*Supported media and data formats
*Etc.
It’s better to make decisions based on characteristics than model number, because then you’ll be better equipped to handle future devices.Using ASP.NET’s built-in browser detection support
ASP.NET Web Forms and MVC developers can immediately discover important characteristics of a visiting browser by inspecting properties of the Request.Browser object. For example, see
Free spins are the most popular type of casino bonus promotion. BonusFinder is the biggest free spins bonus site in the UK. These casino free spins are quite hard to find as the casino’s bonuses change all the time. » It is possible to get slots free spins no deposit bonuses. We provide high quality no deposit bonuses and free online casino offers to our visitors. Since we’re a bigger than usual casino bonus guide in the UK we can negotiate offers like exclusive no deposit free spins and bonuses. In this list, “free spins” means no deposit and “extra spins” mean after deposit! Find all free spins casinos. The biggest no deposit casino bonuses can reach up to £50, which is a huge amount for a bonus that requires no deposit or cash-in. Free Spins, aka Extra Spins Another noteworthy bonus that deserves your attention relates to free spins, which are undoubtedly famous among the UK. Online casino free signup bonus no deposit required usa.
*Request.Browser.IsMobileDevice
*Request.Browser.MobileDeviceManufacturer, Request.Browser.MobileDeviceModel
*Request.Browser.ScreenPixelsWidth
*Request.Browser.SupportsXmlHttp
*…and many others
Behind the scenes, the ASP.NET platform matches the incoming User-Agent (UA) HTTP header against regular expressions in a set of Browser Definition XML files. By default the platform includes definitions for many common mobile devices, and you can add custom Browser Definition files for others you wish to recognize. For more details, see the MSDN page ASP.NET Web Server Controls and Browser Capabilities.Using the WURFL device database via 51Degrees.mobi Foundation
While ASP.NET’s built-in browser detection support will be sufficient for many applications, there are two main cases when it might not be enough:
*You want to recognize the latest devices(without manually creating Browser Definition files for them). Note that .NET 4’s Browser Definition files are not recent enough to recognize Windows Phone 7, Android phones, Opera Mobile browsers, or Apple iPads.
*You need more detailed information about device capabilities. You may need to know about a device’s input method (e.g., touch vs keypad), or what audio formats the browser supports. This information isn’t available in the standard Browser Definition files.
The Wireless Universal Resource File (WURFL) project maintains much more up-to-date and detailed information about mobile devices in use today.
The great news for .NET developers is that ASP.NET’s browser detection feature is extensible, so it’s possible to enhance it to overcome these problems. For example, you can add the open source 51Degrees.mobi Foundation library to your project. It’s an ASP.NET IHttpModule or Browser Capabilities Provider (usable on both Web Forms and MVC applications), that directly reads WURFL data and hooks it into ASP.NET’s built-in browser detection mechanism. Once you’ve installed the module, Request.Browser will suddenly contain a lot more accurate and detailed information: it will correctly recognize many of the devices previously mentioned and list their capabilities (including additional capabilities such as input method). See the project’s documentation for more details.How Web Forms applications can present mobile-specific pages
Hollywood free slots online. By default, here’s how a brand new Web Forms application displays on common mobile devices:
Clearly, neither layout looks very mobile-friendly – this page was designed for a large, landscape-oriented monitor, not for a small portrait-oriented screen. So what can you do about it?
As discussed earlier in this paper, there are many ways to tailor your pages for mobile devices. Some techniques are server-based, others run on the client.Creating a mobile-specific master page
Depending on your requirements, you may be able to use the same Web Forms for all visitors, but have two separate master pages: one for desktop visitors, another for mobile visitors. This gives you the flexibility of changing the CSS stylesheet or your top-level HTML markup to suit mobile devices, without forcing you to duplicate any page logic.
This is easy to do. For example, you can add a PreInit handler such as the following to a Web Form:
Now, create a master page called Mobile.Master in the top-level folder of your application, and it will be used when a mobile device is detected. Your mobile master page can reference a mobile-specific CSS stylesheet if necessary. Desktop visitors will still see your default master page, not the mobile one.Creating independent mobile-specific Web Forms
For maximum flexibility, you can go much further than just having separate master pages for different device types. You can implement two totally separate sets of Web Forms pages – one set for desktop browsers, another set for mobiles. This works best if you want to present very different information or workflows to mobile visitors. The rest of this section describes this approach in detail.
Assuming you already have a Web Forms application designed for desktop browser

https://diarynote.indered.space

コメント

最新の日記 一覧

<<  2025年7月  >>
293012345
6789101112
13141516171819
20212223242526
272829303112

お気に入り日記の更新

テーマ別日記一覧

まだテーマがありません

この日記について

日記内を検索