ASP.NET etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
ASP.NET etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

ASP.NET formun otomatik yenilenmesi



ASP.NET'te bir form üzerinden yeni bir form açıldığında, geri dönüşte ilk formun yenilenmesi için 2. forma aşağıdaki kod eklenir.


<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body onunload="javascript:window.opener.location.reload();">


How to Merge ASP With HTML

Merging ASP and HTML enables you to create a dynamic website with a wealth of information.
Below is an illustration of how to create an ASP page for classic ASP and ASP.NET 2.0that show the login credentials of a user.


1.Write the programming language you will use for the ASP code. Your options are VBScript, JavaScript and VB or C# for ASP.NET.

Classic ASP
< %@Language="VBSCript,"

ASP.NET
< %@Page Language="VB," %>

2.Name the HTML Header and part of BODY section
< HTML>
< HEAD>
< TITLE >Login Page< /TITLE >
< /HEAD >

3. Begin the BODY section

< BODY BGCOLOR="White" TOPMARGIN="10" LEFTMARGIN="10" >

< FONT SIZE="4" FACE="ARIAL, HELVETICA" >
< B >Login Page< /B>< /FONT >< BR >

< HR SIZE="1" COLOR="#000000" >

4. Put ASP code within the HTML text


You logged in as user: <%= Request. ServerVariables ("LOGON_USER") %>



< P>You were authenticated using:< B> < %= Request.ServerVariables("AUTH_TYPE")% >< /B> authentication.

5.Insert the closing Tags for BODY and HTML
< /BODY>
< /HTML>

6. Save the file. Use .asp for classic ASP file and .aspx for ASP.NET file.
e.g UserCredential.asp or UserCredential.aspx

ASP .NET: Visual Studio 2005 Generating Error:

Error :

Could not load file or assembly 'RichChart.RichChart, Version=1.0.128.0, Culture=neutral, PublicKeyToken=9de888868d1712bc' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)

Resolution:

First make sure that the virtual directory is an application byright clicking virtual directory and select propertieson virtual directory tab make sure application is not grayed out if so create application.

Second is the folder that contains the source not actually on the server? Is it on the xp workstation if so take a look at this article on creating a code trust between the server and the workstation.
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q320268

Clear Cookie in ASP.NET

Delete all cookies:

VB.NET:

Dim i As Integer
Dim cookieName As String
Dim limit As Integer = Request.Cookies.Count - 1
For i = 0 To limit
aCookie = Request.Cookies(i)
aCookie.Expires = DateTime.Now.AddDays(-1)
Response.Cookies.Add(aCookie)
Next


C#:

private int i;
private string cookieName;
private int limit = Request.Cookies.Count - 1;
for (i = 0; i <= limit; i++)
{
aCookie = Request.Cookies[i];
aCookie.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(aCookie);
}

How to create and write to a browser cookie in ASP.NET using C#

1- Go to the code-behind of the .aspx page you wish to create the browser cookie from. I will show 2 approaches on creating such a cookie.
2- Method 1:

// A cookie called "userInfo" is dynamically created and the key "userName" is assigned the value "patrick".
Response.Cookies["userInfo"]["userName"] = "patrick";
// A new key called "lastVisit" is added to the collection of values in the cookie and assigned the current datetime value.
Response.Cookies["userInfo"]["lastVisit"] = DateTime.Now.ToString();
// The expiration value of the cookie is set to 1 day in the future from the current date.
Response.Cookies["userInfo"].Expires = DateTime.Now.AddDays(1);
3- Method 2:

HttpCookie aCookie = new HttpCookie("userInfo");
// The key "userName" is added to the cookie and assigned the value "patrick" as the above example.
aCookie.Values["userName"] = "patrick";
// The key "lastVisit" is added to the cookie and assigned the current datetime value.
aCookie.Values["lastVisit"] = DateTime.Now.ToString();
// The expiration date of the cookie is set to 1 day in the future from the current date.
aCookie.Expires = DateTime.Now.AddDays(1);
// Add the cookie to the browser cookie collection.
Response.Cookies.Add(aCookie);

How to Develop a Multi Tier Web Application in Visual Studio .NET 2008 - Part 1

A .NET multi-tier application (also known as an n-tier application) is an application that is composed of 3 or more functional layers. Typically, such an application contains one layer for the presentation interface, another for the business process functionality, and one more for the data handling logic. Today I will show you how to create a C# multi-tier web application in Visual Studio 2008. Due to the many steps involved I have broken up this article into multiple parts. In this section (Part 1). I will show you how to create the folder structure.

INSTRUCTIONS:

1.First we will create a Visual Studio Solution. The Solution will be the top level container for the tiers in our multi-tier application. Open Visual Studio and under the File menu select “New Project”. The “New Project” window will open.

2.In the "New Project" window open the “Other Project Types” node and select “Visual Studio Solutions”. Click on the “Blank Solution” template. Select “.NET Framework 3.5” from the dropdown list. Name the solution “NTierSolution”. Browse to the folder where you would like the solution stored. Click OK.


3.Now that the Solution has been created we can start adding projects to it. Each project will represent one tier in our multi-tier application. We will begin by adding the Presentation tier to our application. In the Solution Explorer, right click the newly created solution and select “Add” and “New Project”.


4. In the “New Project” window open the “Visual C Sharp” node and select the “ASP.NET Web Application” template. Select “.NET Framework 3.5” from the dropdown list. Name the project “NTierWeb”. In the “Location” box, leave the location pointing to the Solution folder so that the new project gets created under it. Click OK.


5.The Solution Explorer should now show the Web Project you just added. The solution is no longer visible in the Solution Explorer.




6.Open Windows Explorer and navigate to the folder that contains your solution. You will see that the solution is still there and now it contains the folder with your Web Project.

7. So far, we have created a Visual Studio Solution and added a Web Project to the solution. The Web Project we just added is our Presentation layer. We will now add a Business Process layer to our solution. Go back to Visual Studio and close the Default.aspx page if it’s open. Then in the File menu select “New Project”. In the “New Project” window open the “Visual C#” node and select the “Class Library” template. Select “.NET Framework 3.5” from the dropdown list. Name the solution “BusinessProcessLayer”. In the “Location” box, leave the location pointing to the Solution folder so that the new project gets created under it. Finally, in the solution dropdown list make sure you select “Add to Solution”. Click OK.

8.Notice that in Solution Explorer our solution is visible again with the projects underneath. This is because we now have more than one project.


9.We will now add the Data Handling tier to our multi-tier application. Go back to Visual Studio and close the Class1.cs page if it’s open. Then in Solution Explorer, right click the solution and select "Add Project".


10.In the "New Project" window open the “Visual C#” node and select the “Class Library” template. Select “.NET Framework 3.5” from the dropdown list. Name the solution “DataLayer”. In the Location box, leave the location pointing to the Solution folder so that the new project gets created under it. Click OK.

11.And that’s it. You have created the structure for a multi-tier application. See the image in this step. Your solution and projects in Visual Studio should now look like the image.




12.In Windows Explorer, navigate to the folder that contains your solution. See the image in this step. Your folder structure should look like the image.











13.The next step would be to add some functionality to your multi-tier web application. Please read my article “How to Develop a Multi-tier Web Application in Visual Studio.NET – Part 2”.

How to Block SQL Injection Hackers with ASP Validation

Protect your database-driven ASP website from hacker attacks with powerful input validation. This will slow down hackers who use methods like SQL injection attacks and XSS (cross-site scripting) via the URL querystring and form inputs. These methods are simple enough that you can do it yourself with only basic coding knowledge.
Step 1
The first goal of a hacker is to repeatedly try to break a website, causing it to display a variety of valuable errors that give away private database details. In this way, he can gain insight into the structure of the database and ultimately create a map or footprint of all its tables and columns. The second goal of the hacker is to actually manipulate the database by executing scripts in malicious ways. With control over the database, the hacker may possibly steal credit card numbers, erase data or infect it with viruses, among other nasty things. In essence, the URL querystring and textbox are the two backdoors into a database. Getting errors and manipulating the backdoors are the two methods used by hackers to ultimately destroy a database. For more details, see my companion article in the resources section or at http://www.ehow.com/how_4434719_protect-website-hacker-attacks.html .
Step 2
Block input containing malicious code.The number one way to block a hacker from manipulating the URL querstrying and textboxes is to block their input. But, how do you determine who they are, what they will input and whether or not it is safe? Unfortunately, you cannot know. So, you must assume that all user input could be potentially dangerous. A common saying in the programming world is that ALL INPUT IS EVIL. Thus, it must be treated with caution. Everything from everybody should be checked every time to ensure dangerous code does not slip in. This is accomplished by checking all input that is submitted via a querystring or form and then rejecting or removing unsafe characters before it ever reaches the database. If this sounds like a lot of trouble, you are right. But, it is the price we pay to protect our websites and databases from the wrath of hackers. It is your responsibility as the webmaster to ensure that only clean, safe input is allowed to enter your database.
Step 3
Input validation.To check if the input entered into the URL querystring or textbox is safe, we can use input validation rules. In other words, using ASP code on a web page can validate the input collected from the querystring or form to make sure it contains only safe characters. Once the input is deemed safe, it can be stored in a new variable, inserted into the SQL string and sent to the database.
Step 4
The wash and rinse cycle.Input validation should be a two-part process, like a wash and rinse cycle. We want to thoroughly clean all input by first checking for safe characters and second by checking for bad strings. See the resources at the end of this article for a more in depth discussion on this method.
Step 5
Only allow safe characters.Part one of the validation process is to reject all input unless it contains safe characters. This is the strictest and most effective form of input validation. It only allows input that is known to be good. Essentially, letters and numbers can be trusted. Special characters are the real culprits which give hackers their power and should be avoided. This extreme measure may not be feasible for all types of input, but try to restrict as many special characters as possible. See the resources at the end of this article for a more in depth discussion on this method.
Step6
Following is an ASP example that could be used for a login or search input field. It allows only a-z, A-Z, 0-9 and an apostrophe, hyphen and space. You can modify the function to include characters as you see fit. %'validation allows only good charactersfunction valGoodChars(input)good_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'- "valGoodChars = truefor i = 1 to len(input)c = mid(input, i, 1)if (InStr(good_chars, c) = 0) thenvalGoodChars = falseexit functionend ifnextend function'collect the form inputsearchInput = Request.QueryString("searchKeyword")‘if an unsafe input is entered the user is asked to try againif (not valGoodChars(searchInput)) thenresponse.redirect("sorryTryAgain.asp")end if%>Remember to use a solution that best fits your website or consult a professional.
Step 7
Part two of the validation process is to reject all input if it contains bad strings. After you have collected good input with the method above, you should check it again for input that is known to be bad. Dangerous things could happen if the good character function allowed an apostrophe and hyphen, or other letter combinations like SCRIPT, SELECT, UPDATE, DELETE, etc. That is why the bad string function should be used in conjunction with the good character function. See the resources at the end of this article for a more in depth discussion on this method.
Step 8
Following is an ASP example that rejects bad characters and should be used after checking for good characters. Bad characters could include a pair of hyphens and the word script, among other things. You can modify the function to include the bad strings as you see fit. |%'validation disallows bad stringsfunction valBadStrings( input )bad_strings = Array( "--", "script" )for each i in bad_stringsif ( InStr( input, i ) <> 0 ) thenvalBadStrings = falseexit functionend ifnextvalBadStrings = trueend function‘if an unsafe input is entered the user is asked to try againif (not valBadStrings(searchInput)) thenresponse.redirect("sorryTryAgain.asp")end if%>Remember to use a solution that best fits your website or consult a professional.
Step 9
Safely query the database.Now that the input has been laundered through the good and bad functions, it is ready to be inserted into the SQL query and executed by the database. Following is sample ASP code that inserts the searchInput. queries the database for a match, then displays the results.<%'check the database for a matchSet myRecordSet = Connect.Execute ("SELECT * FROM dbo.myTable WHERE myColumn LIKE '%" & searchInput & "%'")'display the resultsif myRecordSet.EOF then'display message no results foundelse'display resultsend if end if%>By validating the input before sending it to the database you have greatly reduced the risk of your database being compromised by hackers.
Step 10
Filter characters.Another method that can be used in conjunction with the above two functions, but is considered to be very weak when used alone, is to sanitize the input by filtering or escaping. A well-known threat is the single quote or apostrophe because it breaks the SQL statement. Following is an ASP example that renders the single quote harmless, by replacing it with two single quotes.'doubleup single quotesnewSafeString = replace(searchInput, "'", "''")Other variations for the replace function include stripping out the script tag and replacing it with a space. Or, filter out characters such as the dollar sign $ quotation mark “ semi-colon ; and apostrophe ‘ the left and right angle brackets <> the left and right parentheses ( ) the pound sign # and the ampersand &. Or convert these characters to their HTML entities.Remember to use a solution that best fits your website or consult a professional.
Step 11
If you would like to pursue more advanced security techniques, please see the resources at the end of this article. Topics discussed include, password policies, buffer overrun, creative table and column names, table name aliases, set and check data types, .bak files, stored procedures with parameters, and log files.

ASP.NET compile Error : Reply from ::1: time<1ms

Problem:
Whenever a project or a file is run, the address http://localhost:// fails to load on all browsers. I disabled/enabled proxy servers with exclusions and what not to see if it was the proxy that was causing this, but had no luck at all. Funny enough, if I manually change the address to http://127.0.0.1://, the website which I am debugging/running loads.


Command:> ping localhost
Pinging hong001 [::1] with 32 bytes of data:
Reply from ::1: time<1ms sent =" 4," received =" 4," lost =" 0" minimum =" 0ms," maximum =" 0ms," average =" 0ms">ping 127.0.0.1
Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms ttl="128" bytes="32" ttl="128" bytes="32" ttl="128" bytes="32" ttl="128" sent =" 4," received =" 4," lost =" 0" minimum =" 0ms," maximum =" 0ms," average =" 0ms">Solution:
You must be disable IPv6 on your Computer.

HOW to Disable IPv6:

  • Windows XP: Start->Run->cmd /k ipv6 uninstall
  • uninstallUnlike Windows XP, IPv6 in Windows Vista cannot be uninstalled.

Visual Studio 2017'de Devexpress 17.2.5 Toolbox görünmüyor

Visual Studio 2017 Toolbox'ı üzerinde Developer Express componentlerini göremiyorsanız aşağıdaki komutu çalıştırmak işini görecektir. (...