.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
abhays
satyapriyanayak
SP
Ashutosh Jha
ASPEvil
Post New Web Links

IP address range check

Posted By:      Posted Date: September 24, 2010    Points: 0   Category :ASP.Net
 

Hi There,

I having a problem in getting the ip address of the client. I need to check a Ip and if it is within a range then, it should use resource from local intranet otherwise it should use the web content.  I tried all the below methods. These methods return a three different  ip address on the local sharpoint hosted site, development and production server. also when i check the ip using ipconfig, it is different to the returned ip's. any help would be great !! 

string ClientIP = Request.ServerVariables["remote_addr"].ToString();

---------------------------------------------------------------------------------------------
     
string ClientIP1 = Request.UserHostAddress;

-------------------------------------------------------------------------------

string ipaddress;

ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

if (ipaddress == "" || ipaddress == null)

ipaddress = Request.ServerVariables["REMOTE_ADDR"];
-------------------------------------------------------------------------------------------

string strHostName = System.Net.Dns.GetHostName();
string strIp = System.Net.Dns.GetHostAddresses(strHostName).GetValue(1).ToString(); 

-----------------------


View Complete Post


More Related Resource Links

An unrecognized HTTP status was received. Check that the address can be accessed using Internet Expl

  

Hi All,

I am getting following error message in my crawl logs.

An unrecognized HTTP status was received. Check that the address can be accessed using Internet Explorer. (WebExceptionStatus KeepAliveFailure The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.)

Any idea how to solve this issue ?


Range dimension: how to address this requirement?

  
Hi All,

Let me describe the requirement using 'FactInternetSales' table.

I have a Date_Range dimension with members 7 days, 14 days, 30 days, etc. To associate this dimension I need
DateRangeKey in the FactInternetSales table but FactInternetSales doen't have TimeKey (it has OrderDateKey, DueDateKey, ShipDateKey).
So how I can calculate DateRangeKey in the FactInternetSales named query using OrderDateKey, DueDateKey or ShipDateKey as they relate to their respective dimension but I need DateRangeKey from TimeKey (I guess OrderDateKey - 7, etc would work instead of TimeKey )?

Without Date_Range dimension I can meet some of my reporting requirement using filter or range operator but not all and for
performance I would like to use Date_Range dimension instead of filter or range.

Any help will be greatly appreciated.

Thanks

reg exp for check input textbox ip address with padded leading zeros

  

Hi all!

I'm new in this forum...

I want a regexp to check a input textbox with a ip address ipv4 with all the controls for a valid ip address but:

for example: 192.168.0.15 62.1.5.123 is not correct for me but i want only 192.168.000.015 or 062.001.005.123 ....

is it possible only with regular expressions?

Thanks

Paolo


Using a CompareValidator to check input is a valid date

  
The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

Check All with JQuery and a Asp.Net GridView

  
Display a Grid on the screen with a checkbox in each row. At the bottom of the page have "Check All" button.

Typically if I need to do anything interesting I use a template column. So my GridView will look like the one below (most other columns removed for readability). The only interesting point to note is the CssClass="ApprovalCheckBox" in the CheckBox ItemTemplate.

IP Address Blocking or Restriction in SQL Server

  
"is it possible to block connections to SQL Server based on IP address". As far as now there is no official way in SQL Server to block the connections in SQL Server based on IP address. However this can be done from the OS end, we have the following three options available, refer HERE for more.


.Firewall
.IPSec
.RRAS IP Filter

my ip address

  
IP Tejji answers question like what is my ip address? find my ip addresss? detect my ip address? Best part is it also determines your local ip address as well as mac address. Further if you keen on browser specification and details regarding browser capabilities can also be found. It also help you see your geographic location. Other details that are available are Latitude, Longitude, timezone, country, region & city. In short it is one-stop-shop for very rich details about your IP and related information.

check box control

  

Hi ,

I have a three check box in my web form ,i need to choose only one check box, if i choose one check box

another 2 check box automatically unchecked

can i use jquery for check box


I thought this would be simple... Trying to create a login does an ajax check before submit

  

I have the standard .net login control that is working.  (Still learning .net after 15yrs of classic)

What I want to do is OnButtonClick run a javascript function (to do an ajax call to the db to check if login is valid or not) and if it returns true, then submit the form normally, else don't submit. The piece that I can't figure out, is how to correctly override the default click even to hit my JS routine and then submit the form properly afterwards.

Thanks ahead of time


ListViewControl - how to group items by their value, for eg. date range

  

Hi,

I have a table containing courses, columns are 

Name - "Yoga Classes"

DateStart - "2/23/2010"

DateEnd - "2/24/2010"

I am using ListView Control to bind it, is there a way to display them and group them by Month? 

for eg.


January

Piano Class (10th Jan 2010 - 11th Jan 2010)
Guitar Class (10th Jan 2010 - 11th Jan 2010)

February 

Yoga Class (15th Feb 2010 - 16th Feb 2010)
 etc...


Thanks for help.


how to check a textbox value in jquery?

  

Hi,

I want to perform some action when an asp.net textbox value length is greater than 1 character. And for this I wanted to know how to write this check in jquery?

I have created a check like below-

if ($('[id=txtUserInput]').val().length > 2)
{ do some work...} 


But its giving me the following error


$("[id=txtUserInput]").val() is undefined


Can anybody let me know the right way of doing this?


Regards,

Dazy


How to check for null/empty strings on dynamic objects?

  

What is the proper way to check for null or empty strings on dynamic objects? This is the only solution I've found so far:

if (admin.PasswordHash.GetType() == typeof(DBNull) || admin.PasswordHash == string.Empty)

If the field is null, the object returned is DBNull.Value, but if the field is empty string, it's return as a System.String object. This makes it impossible to do regular "admin.PasswordHash == DBNull.Value" check, as that will fail whenever the field has been set to empty string. Is my example the right (and only) way to go?


Automatically redirect to HTTPS and check if SSL is active

  

Hello,

I've set in the web.config:

    <!-- User Authentication -->
    <authentication mode="Forms">
      <forms loginUrl="~/Page/View/Content/Login.aspx" timeout="2880" requireSSL="true" />
    </authentication>


This works fine. If there is no ssl connection, the login form doesn't continue. But I would like to check if ssl is active (in codebehind) and, if it's possible, to automatically the user to the https page if he's currently on http. (I could do this job by manually redirect with page.response("https://url.../login.aspx"); but this is not really generic. For example if the webapp is moved to another domain it doesn't work anymore... I'm looking for something like: FormsAuthentication.RedirectWithSSL(); or so... :D)

Regards,
Chris 



how to check which pages of my site that my visitor visiting at the moment

  

 Hi all, and thanks a lot for the replies since now. I have a new question :

I prepared a simple instant messaging system for my web site and i would like to learn which visitor (registered member) is at which page of my site. 

For example : 

Uid:10000, Username:donald, NameSurname:Donald DUCK is a registered and signed in visitor.

I need the code which tells me that visitor is at which page (ie. images.aspx?imageid=143223)

Sorry for my poor english, and let me know if i should explain more clearly :)

Have a good evening...


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend