473,324 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Left function

I am attempting to collect the user's IP address from a Web App. I then need
to verify the address is not an 'internal' user. I need to compare the left 3
characters of the IP address with a constant. I know I have done this with
the left function in VB. I can't seem to locate a similar function in C#. Can
someone assist?

if (Session["UserIP"].ToString() == "22.")
Mar 22 '06 #1
2 6047
Look at String.StartsWith().

"so*******@hotmail.com" wrote:
I am attempting to collect the user's IP address from a Web App. I then need
to verify the address is not an 'internal' user. I need to compare the left 3
characters of the IP address with a constant. I know I have done this with
the left function in VB. I can't seem to locate a similar function in C#. Can
someone assist?

if (Session["UserIP"].ToString() == "22.")

Mar 22 '06 #2
You can do in different ways:
you can :
1. Use string.Substring; to get the idex of first dot you can use
string.IndexOf

2. You can split the string on dots - string.Split('.') and get an array of
IP parts.

3. You can use string.StartsWith("22.") if the "22." is the only option.
--
HTH
Stoitcho Goutsev (100)

"so*******@hotmail.com" <so*****************@discussions.microsoft.com>
wrote in message news:4C**********************************@microsof t.com...
I am attempting to collect the user's IP address from a Web App. I then
need
to verify the address is not an 'internal' user. I need to compare the
left 3
characters of the IP address with a constant. I know I have done this with
the left function in VB. I can't seem to locate a similar function in C#.
Can
someone assist?

if (Session["UserIP"].ToString() == "22.")

Mar 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: lawrence | last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this script hoping to animate some div blocks on a page. You can see the page here: http://www.keymedia.biz/demo.htm Can anyone...
1
by: Martin Lira | last post by:
Hi, I have a webapp that has several jsp pages. The main page has a left nav and it loads the sub pages when requested. Can somebody please give an easy way to track the jsp page you are currently...
5
by: gsb | last post by:
I track the mouse location like this code: function mousePos(e) { var p = new Object(); if(e) { p.x = e.pageX; p.y = e.pageY; } else { p.x = event.x; p.y = event.y; } ... (show) }...
17
by: Nathan Given | last post by:
Hello All, I am trying to debug a broken query. The query uses Left$(,4) instead of Left(,4). What is the difference between the Left() and Left$() functions in Microsoft Access? Thanks!...
4
by: Agnes | last post by:
in .net , any left function ?? or I should use Microsoft.VisualBasic.Left(myString, 5) Thanks
18
by: Jm | last post by:
Hi all I feel stupid for asking this, but i just went to use the left() function from vb6 only to find it doesnt do what it used to under .NET. Im assuming theres something else now im meant to...
8
by: marco | last post by:
Hi ! I have this part of code and i can not find out why the scroller is starting from left to right instead RIGHT to LEFT. This is the main part and the scroller is working fine but from the...
9
by: sql guy123 | last post by:
I normally use MS ACCESS vs MS SQL,, which has a left() and right() function. I need to use MS SQL for this project but I am not familiar with it. I have read a few books, but can not figure out...
6
by: =?Utf-8?B?R3JlZw==?= | last post by:
I have two questions with regards to the LEFT function. I ran into a problem with the LEFT function today. I knew it was a valid Function, but when I tried to use it, it was getting interpreted...
1
by: Lagon666 | last post by:
Hi How can i stick tabs to left. Now it has 40px distance to left. <style> #Content { background-color: #fafafa; border: 1px solid #a2b6cb; padding: 10px;
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.