Wickasitha's tech Blog

blogging everything

Archive for the ‘Tips & Tricks’ Category

A potentially dangerous Request.Path value was detected from the client (?).

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: A potentially dangerous Request.Path value was detected from the client (?).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): A potentially dangerous Request.
Path value was detected from the client (?).]
   System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +8884233
   System.Web.ValidateRequestExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +35
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Solution

<system.web>

        <httpRuntime requestValidationMode=”2.0″ requestPathInvalidCharacters=”" />
        <pages validateRequest=”false” />
this worked form me.

How to Hide Your Friends on Facebook

Do you want to hide your list of friends from people in it? Facebook offers facility to stop showing them on your Profile or Timeline. This post will show you how to hide them both in the old Profile and in the new Timeline.

How to do it in the old Profile

Once you have logged in to Facebook, on the top right hand corner of the page, click on your name or small profile picture and then on the “Edit Profile” button that will appear right below.

Once you have done this, in the left sidebar, click on the option that says “Friends and Family.”

Now, at the right extreme of the Friends section, located near the bottom center of the screen, click on the audience icon, the one indicated in the next image, and in the appearing menu select the option “Only Me.”

Finally, click on the “Save Changes” button, located near the bottom of the screen.

Keep in mind that, although your list of friends will not appear on your Profile, there are still other ways in which people may see it. This is because in December 2009 Facebook declared that all users’ lists of friends are public information.

How to do it in the new Timeline

Once you have logged in to Facebook, on the top right hand corner of the page, click on your name or small profile picture.


Then, click on the Friends box that is among the boxes that are right under your name and big cover picture.

Once you have done that, click on the “Edit” button near the top right hand corner of the page, then click on the audience icon, and finally, in the appearing menu, on the “Only Me” option. The three things that you have to click are pointed in the next image:

This way people that see your Friends box on your Timeline will only see in it their mutual friends among you and them. Mutual friends with the viewer cannot be hidden.

Finding a Facebook Profile from an Image

Let’s say someone has posted a picture from Facebook on another site such as sample.com using the Facebook URL (hotlinking.) Here is how you find the profile where that picture came from:
1. Find the URL of the image. If you don’t know how, right click on the image -> View Image
2. Open a new tab or window and paste into the address bar http://www.facebook.com/profile.php?id=
3. Look at the image URL and pick out the third number from the right eg http://sphotos.ak.fbcdn.net/hphotos-…_1111111_n.jpg
4. Copy that number (from example 333333333333333) and paste next to the ?id= so you have a new URL of the form http://www.facebook.com/profile.php?id=333333333333333
5. Hit enter and this is the profile the image came from!

Image URL is correct but image not showing – Fixed

I have a website on my server. All permissions are set correctly and the image DOES exist. Howeverwhen the page loads the image for the item selected does not show. Here is my code

 imagepath = "~/spaimages/" + currentSpaModel.Name.ToString() + ".png";     
    if (File.Exists(Server.MapPath(imagepath))) { this.spaimage.ImageUrl = Server.MapPath(imagepath); }
spaimage is an ASP control and thr URL that the image is set to is D:\hosting\xxxxxxx
\calspas\spaimages\modelname.png 
Fixed

The file path D:\hosting\xxxxxxx\calspas\spaimages\modelname.png is the folder where theimage resides on the web server. You are sending this as the <img> tag’s src attribute, which tellsthe browser, “Go get the image at D:\hosting\xxxxxxx\calspas\spaimages\modelname.png.”The browser cannot go off to the D drive of the web server, so it looks on its own D drive for that folder and image.

What you mean to do is to have the <img> tag’s src attribute be a path to a folder on the website. You’re just about there – just drop the Server.MapPath part when assigning the image path to theImageUrl property. That is, instead of:

this.spaimage.ImageUrl = Server.MapPath(imagepath);

Do:

this.spaimage.ImageUrl = imagepath; 

it works !!!


Here’s a stored procedure named, SearchAndReplace, that searches through all the character columns of all tables in the current database, and replaces the given string with another user provided string. It accepts a search string and a replace string as input parameters, goes and searches all char, varchar, nchar, nvarchar columns of all tables (only user created tables. System tables are excluded), owned by all users in the current database and replaces all occurences of the search string with the replace string.

The output of this stored procedure shows you how many occurences of the string are replaced. Sample output would look something like this:

Result
—————————————————-
Replaced 55 occurence(s)

Create this procedure in the required database and here is how call it:

–To replace all occurences of ‘America’ with ‘USA’:
EXEC SearchAndReplace ’America’, ‘USA’
GO

Here is the complete stored procedure code:

(more…)

If you are working with VS 2010 (any Edition) and cannot open your 2010 solution on VS 2008 then just follow these 3 Steps:

For <PROJECT_NAME>.sln:

1. Open the solution file in your favorite text editor (ex: notepad++).
2. Find the Following:
Microsoft Visual Studio Solution File, Format Version 11.00.
# Visual Studio 2010.
Replace with:
Microsoft Visual Studio Solution File, Format Version 10.00. (I)
# Visual Studio 2008. (II, optinal)

For <Project_name >.csproj/vbproj:

1. Open project file in your favorite text editor (ex: notepad++).
2. Find the Following:
<Project ToolsVersion=”4.0″ DefaultTargets=”Build” xmlns=”http://schemas.microsoft.com/developer/msbuild/2003″>.
Replace with:
<Project ToolsVersion=”3.5″ DefaultTargets=”Build” xmlns=”http://schemas.microsoft.com/developer/msbuild/2003″>. (III)

Thats it..
Now you can open your solution file on VS2008.
Reverse of this will enable VS2008 solution to open in VS2010.

Compare two tables in SQL Server

Assuming we are comparing tables A and B, and the primary key of both tables is ID:

SELECT MIN(TableName) as TableName, ID, COL1, COL2, COL3 …

FROM

(

SELECT ‘Table A’ as TableName, A.ID, A.COL1, A.COL2, A.COL3, …

FROM A

UNION ALL

SELECT ‘Table B’ as TableName, B.ID, B.COL1, B.COl2, B.COL3, …

FROM B

) tmp

GROUP BY ID, COL1, COL2, COL3 …

HAVING COUNT(*) = 1

ORDER BY ID
The above returns all rows in either table that do not completely match all columns in the other.  In addition, it returns all rows in either table that do not exist in the other table.  It handles nulls as well, since GROUP BY normally consolidates NULL  values together in the same group.  If both tables match completely, no rows are returned at all.

The MIN() aggregate function used on the TableName column is just arbitrary — it has no effect since we are only returning groups of rows in which there has been no consolidation with the GROUP BY (note the HAVING clause).

I’ve posted an implementation of this technique as a stored procedure.Here it is, below:

CREATE PROCEDURE CompareTables(@table1 varchar(100),

@table2 Varchar(100), @T1ColumnList varchar(1000),

@T2ColumnList varchar(1000) = )

AS

– Table1, Table2 are the tables or views to compare.

– T1ColumnList is the list of columns to compare, from table1.

– Just list them comma-separated, like in a GROUP BY clause.

– If T2ColumnList is not specified, it is assumed to be the same

– as T1ColumnList.  Otherwise, list the columns of Table2 in

– the same order as the columns in table1 that you wish to compare.

– The result is all rows from either table that do NOT match

– the other table in all columns specified, along with which table that

– row is from.

declare @SQL varchar(8000);

IF @t2ColumnList = ” SET @T2ColumnList = @T1ColumnList

set @SQL = ‘SELECT ”’ + @table1 + ”’ AS TableName, ‘ + @t1ColumnList +

‘ FROM ‘ + @Table1 + ‘ UNION ALL SELECT ”’ + @table2 + ”’ As TableName, ‘ +

@t2ColumnList + ‘ FROM ‘ + @Table2

set @SQL = ‘SELECT Max(TableName) as TableName, ‘ + @t1ColumnList +

‘ FROM (‘ + @SQL + ‘) A GROUP BY ‘ + @t1ColumnList +

‘ HAVING COUNT(*) = 1′

exec ( @SQL)


 

Pages (4): 1 2 3 4 »

RSS Feeds

QR Code

qr code

QR code created by QR code Widget

Fun with .NET

Visitors

Your Ads Here
Promote your products