Ramadurai_Hariharaputhran
asked on
How to block specific website through vb.net web application
Hi,
How to block a website in vb.net web application without using a localhost ip (127.0.0.1) & proxy server ip address.
Requirement is when am running my application, specific site should get blocked while the application is in running status. Application shouldn't communicate with that specific website.
The code given below doesn't works for me. When running this code it's hitting the specific site.
JavaScript
----------------------
In this JavaScript sample am just creating one function and calling this function from another function.
----------------------
<script type="text/javascript" language="javascript">
function BlockUrl() {
var path = "C:\Windows\System32\drive rs\etc\hos ts";
var sw = new StreamWriter(path, True);
var sitetoblock = vbLf & " 127.0.0.1 xyz.com";
sw.Write(sitetoblock);
sw.Close();
}
function Open() {
BlockUrl();
}
Vb.Net
-------------------
In this vb.net sample am just blocking in Page_Load method itself. But i just want to block site, creating one method and calling that method from another.
-------------------
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.IO
Namespace Sample1
Public Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs)
Dim path As [String] = "C:\Windows\System32\drive rs\etc\hos ts"
Dim sw As New StreamWriter(path, True)
Dim sitetoblock As [String] = vbLf & " 127.0.0.1 xyz.com"
sw.Write(sitetoblock)
sw.Close()
End Sub
End Class
End Namespace
Pls let me know is there any other way to blocking a website using vb.net web application.
How to block a website in vb.net web application without using a localhost ip (127.0.0.1) & proxy server ip address.
Requirement is when am running my application, specific site should get blocked while the application is in running status. Application shouldn't communicate with that specific website.
The code given below doesn't works for me. When running this code it's hitting the specific site.
JavaScript
----------------------
In this JavaScript sample am just creating one function and calling this function from another function.
----------------------
<script type="text/javascript" language="javascript">
function BlockUrl() {
var path = "C:\Windows\System32\drive
var sw = new StreamWriter(path, True);
var sitetoblock = vbLf & " 127.0.0.1 xyz.com";
sw.Write(sitetoblock);
sw.Close();
}
function Open() {
BlockUrl();
}
Vb.Net
-------------------
In this vb.net sample am just blocking in Page_Load method itself. But i just want to block site, creating one method and calling that method from another.
-------------------
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.IO
Namespace Sample1
Public Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs)
Dim path As [String] = "C:\Windows\System32\drive
Dim sw As New StreamWriter(path, True)
Dim sitetoblock As [String] = vbLf & " 127.0.0.1 xyz.com"
sw.Write(sitetoblock)
sw.Close()
End Sub
End Class
End Namespace
Pls let me know is there any other way to blocking a website using vb.net web application.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
once u did, use Server.Transfer or Response.Redirect, to navigate the user to other page.
an alternative is to handle Application.BeginRequest, detect site ip and call Response.End.