Detecting Requests from Mobile Browsers in ASP.NET [duplicate] - asp.net

This question already has answers here:
Mobile Device Detection in asp.net
(9 answers)
Closed 6 years ago.
I have an existing web site and I would like to create a mobile version of it that is more suitable. For instance, the main site uses drop-down menus and we all know those are quite the fail on mobile devices.
I would like to redirect to my mobile version (it will be a subdomain of the current site) if I detect a request from a mobile browser. So when they Google something and come to my site, they will automatically see the mobile version (just like Wikipedia).
Does ASP.NET provide an easy way of doing this? If not, how can I do it?

You can use the IsMobileDevice property somewhere in the Request.Browser. You need some decent browser definitions though. I use these excellent set of browser definitions: Ocean's place browser definitions.
They are really in depth and the best I've seen. I think he is currently working on .NET4 ones too.

I think the best solution is WURFL. It is more up date device description repository and it is free. The only inconvenience is .net api is GPL.

Keep it simple...
Heres the JS for the same...
Hope it helps someone..
var useragent = navigator.userAgent;
var isMobile = !!useragent.match(/iPhone|Android|Blackberry|Sony|Nokia|Motorola|Samsung/i),
isWebBrowser = !!useragent.match(/Mozilla/i);
// Redirect the call accordingly.
if(isWebBrowser && !isMobile)
//call to web portal
alert(" You seem to me... calling from Web Browser")
else if(isMobile)
//call to mobile apps
alert(" Call seems to be from Mobile device...")
else
{
// jus kiddin...
alert(" Unable to detect the device..... Please report to admin...")
}

There is a project on codeplex that you can use : Mobile Device Browser File
Project Description
The Mobile Browser Definition File
contains definitions for individual
mobile devices and browsers. At run
time, ASP.NET uses the information in
the request header to determine what
type of device/browser has made the
request.
This project provides a data file that
when used with ASP.NET will detect the
incoming mobile device and present you
as the web developer with a set of 67
capabilities or properties describing
the requesting device. These
capabilities range from screen size to
cookie support and provide all the
information you need to adaptively
render content for mobile phones and
devices.
What is the Mobile Device Browser Definition File?
The Mobile Device Browser Definition
File contains capability definitions
for individual mobile devices and
browsers. At run time, ASP.NET uses
this .browser file, along with the
information in the HTTP request
header, to determine what type of
device/browser has made the request
and what the capabilities of that
device are. This information is
exposed to the developer through the
Request.Browser property and allows
them to tailor the presentation of
their web page to suit the
capabilities of the target device.

There's an article on CodeProject which provides such function.

Related

Should I use Firebase Dynamic Links over Universal and App Links?

Im building an app for iOS and Android and need to open urls in the app on mobile and in the browser on desktop.
All links should open in the app if possible, so I cant generate one link for each possible url.
Can I do this in Firebase or do I have to create links in advance?
I'm not sure this question is related specifically to Firebase, or a general one.
I can try answering about the general case:
For opening in App:
In order to use Universal Links in iOS and AppLinks in Android, you'll need your click server to host Apple's AASA file or Android's asset file. This means that you'll need to serve that file for the operating system.
For opening in browser on desktop:
You'll need your click server to be able to detect desktop user agent and redirect you to store.
I didn't understand your question about: All links should open in the app if possible, so I cant generate one link for each possible url. Actually one link can fit all use cases, but you'll need to develop that capability in your own click server.

Flex mobile wrap html page

I'm trying to write an AIR application to be deployed on a mobile device.
I have an HTTPS website that I go to and log in using a browser. I can view things in my account, etc.
I want to use my AIR app instead of the HTTPS website. Can I "wrap" or "skin" an html site using AIR?
So I'm looking at StageWebView, URLRequest, URLLoader.
I need to POST things like username, password, and other things.
How can I do it?
See ExternalInterface on AS3 reference that you can use to call Javascript-functions on your site.
You can show HTML content with mx:HTML
If all you need to do is POST or GET, look into HTTPService
You might wanna have a look at the StageWebViewBridge, it has some extended features compared to the default StageWebView
http://code.google.com/p/stagewebviewbridge/
We wanted to use it in a project but ended up in implementing the URL based communication on our own. BUt you should give it a try, mabye it works for you.

ASP.NET website not working properly in mobile

I have created a simple app with a page having a server side form, three fields and a button that submits and performs two operations - 1) adds the form fields to the database table 2) sends an email. Now everything works fine on the web browser on my machine but when I access the app through my mobile, the page does not seem to work. the UI and all are set but the button click functionality doesnt seem to be working and also the label which is set after a successful submit is already visible and showing the "thank you" message. Am i doing something wrong here?
I have checked the app on Nokia Smartphone browser, android phone, and iphone simulator.
1st i would try to access the site from a different computer or through a proxy. Just to make sure things work out well in different browsers. That may catch your bug. It may be working fine on your PC Locally, on a local web server, but may not be uploaded to the web.
Next, I would check to see if the devices you are using support Javascript. Chances are good that your script relies on it.
I strongly recommend you to use JQuery Mobile, it create Mobile friendly interface for your website. and for sure it work the same for each cell phone, but as Asp.net isnot easy to render for most of (old) phones, so that you're not able to use whatever you like.

how to work with videos in ASP.NET?

this is my first time doing a gallery of videos using ASP.NET,
I believe there are many articles on the net regarding this, but I would like to see some recommendation and different point of view :
what are the tools used?
how to not allow user to download a video?
what the difference between vimeo,dimecasts.net choice , what about other choices?
Streaming?
any valuable information will be appreciated.
Dear sam you ask too many different question. I will try to give some answer to what I know.
First you need to select the way you go to show your video. One popular way is the flash. YouTube use flash.
So the tools that you can use is the one that convert the video to flash streaming file. There is all ready one from adobe. Other tools is video editing if this is what you asking for. Video editing with asp.net or with other programs like vegas video.
How to not allow a user to download a video ?, you serve this video from an ashx handler, this handler just read the video file from a protected directory and send it to the video player. The id of the file that is going to play you send the id on the page header, or from inside redirect to that page to hide it as much as you can, but expert users can find it and download it at the end. How ever you can avoid the scanning of your page by a robot that try to download them all. All this is not that easy but not that hard also. This task is a full question and a tutorial alone, and as I say I think that is near impossible to avoid at the end the user not get your video if he won it to.
Other way to protect your video is to scramble the streaming header, and then on your flash player decode it again back. That way even if they get them ,they can not play it anywhere.
About the streaming, adobe give a streaming server http://www.adobe.com/products/flashmediaserver/ but for small video files the flash player combinate with the flash video file can do almost the same work.
flash video player, I think that there are some if you google it, one of them is the flowplayer http://flowplayer.org/
You need to know to programming also flash and probably make communication with the video flash and your pages using Javascript, and modify the player to your needs. All of that its not an easy task, but there are many resources and tutorial that can help you.
So start with the flash video on google.
From tag "asp.net" I'm assuming that you deal with Microsoft technologies. Our team in the past had estimation project around selling video content, so you problem is close to it.
The base idea is usage of Microsoft Windows Media Services 9 Series( for brief overview look at
http://www.microsoft.com/windows/windowsmedia/howto/articles/webserver.aspx ). So this answer #1.
The most difficult question is #2. Because you can just reduce possibility to download, but to watch video user needs have some frames at client side. That is why content always can be intercepted. Following list is my recommendations how to reduce risks:
Use "Stream without downloading" (see article above for details) or broadcast
Manage stream content with Digital Rights Management
Use authentication of users that watch video and provide unique URL for them to disallow special tool of downloading to intercept results.
Question #3 relates to format war. Vimeo, youtube and many others use FLV format to provide video. In theory client-side player of vimeo can play without problem video from youtube and vice verse. The benefit of it is crossplatforming - Linux, Mac, Windows users can recognize this format and play it. On other hand usage of WMV (windows media) potentially can be restricted (in real I have never seen any problem). But usage of Microsoft formats are more secured since usage of Digital Rights Management tags embedded to content.
Answer on #4, #5 you can find in article above.
I would opt for using Silverlight. It has Digital Rights Management and Microsoft has some great tools for you like Expression Blend and Encoder.
For the streaming part you could use IIS smooth streaming.
Hi. I have uploaded a picture to show you the solution better. Now I want to tell you what does this image mean:
Upload Center: You must create upload center to upload your videos. So you need to create a user interface with upload controls. after upload, you should change video format to flash video files (Best file type is FLV). And at last step of upload files must save at specific directory ( I call it #VidDir) and you must get video a specific id (I call it #VidId). So file save at Directory/FileID
Generic Handler: This generic handler can open video (with flash video player) and create <embed> tag (or anything else) to show videos. note: to view video this generic handler must have query string (I call it #VidId).
Flash Video Player: You must create a flash video player or use another ready versions; But its better to create your self. (Its realy easy, trust me). This video player must configure to show videos from web page query string (that I call it #VidId).
At last there must be a web page to use generic handler.
Demo here.
ANSWERS:
1.what are the tools used?
Adobe flash: To create a video player. use can use flash FLV media playback tool for video preview. After that you can use buttons, movieclips, and graphics for customizing your user interface.
Its better to use other Flash video players (e.g->Flow player).
Generic handlers: Generic handlers are best way to picking elements. You can preview generic handlers in your ASP.NET page.
2.how to not allow user to download a video?
You can upload videos to your App_Data folder. To access this folder you must have server permission but generic handlers can access videos there.
3.what the difference between vimeo,dimecasts.net choice , what about other choices?
I dont know. You can take a look at Aparat persian video sharing center.
4.Streaming?
You can take a look at Adobe media server family.

Flex application bookmarking problem/"#" at end of url

I work in an area where the business users heavily depend on bookmarks to access their work-related web applications. Our standard browser is Internet Explorer v6. We have a new Flex application - when you add the site to Internet Explorer Favorites, then later try to access the site with the Favorites link, we get the following error message: "internet explorer cannot open the internet site http://our url. Operation aborted". If we then bring up the properties for the link and remove the trailing "#' from the url, the link works.
What is this trailing "#", and can it be removed? Is there a way to have Internet Explorer bookmarking to work for this site (other than manually editing the bookmark)? The problem doesn't occur in Firefox (but not everyone has access to that browser).
The trailing # is used to provide information to your client-side framework. It was originally meant to provide the ability to link to anchor points in an HTML document. It has been "hijacked" by JavaScript frameworks to provide state information to Flash and Flex applications.
The primary benefit of using # to navigate is that the browser doesn't navigate off the current page - meaning you only need to load your framework once. Traditional URLs would force an entire page reload.
Most likely you can't remove it. You should be able to provide a means for a secondary URL scheme that encodes what you need in a query string (?foobar=1).
You will need to configure server-side processing to either redirect the user to the hash URL or load the necessary information via a JavaScript hook to your Flex framework.
You might also look into the new Google Chrome plugin for IE.
You can turn this off in the compiler parameters in Flex Builder. Go into the project settings, then in "Flex Compiler" uncheck the box that says "Enable integration with browser navigation".

Resources