分类
DotNet

How to make Apache run ASP.NET / ASP.NET 2.0 under windows

Don’t ask me why… but i’ve been asked to make Apache run ASP.NET.

IT Worked ! *
*
Even worked with ASP.NET 2.0 Site !

Following are the instruction to make Asp.Net work under apache:

  • Install [Apache 2.0.54**]
  • Install [Mod_AspDotNet**]
  • Add at the end of C:\Program Files\Apache Group\Apache2\conf\httpd.conf the following lines

asp.net

LoadModule aspdotnet_module "modules/mod_aspdotnet.so"  
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj licx rem resources resx soap vb vbproj vsdisco webinfo

<IfModule mod_aspdotnet.cpp>  
# Mount the ASP.NET /asp application  
AspNetMount /SampleASP "c:/SampleASP"  
#/SampleASP is the alias name for asp.net to execute  
#"c:/SampleASP" is the actual execution of files/folders in that location  
# Map all requests for /asp to the application files  
Alias /SampleASP "c:/SampleASP"  

#maps /SampleASP request to "c:/SampleASP"  
#now to get to the /SampleASP type [http://localhost/SampleASP]
#It'll redirect http://localhost/SampleASP to "c:/SampleASP" 
# Allow asp.net scripts to be executed in the /SampleASP example  

<Directory "c:/SampleASP">  
Options FollowSymlinks ExecCGI  
Order allow,deny  
Allow from all  
DirectoryIndex index.htm index.aspx  
#default the index page to .htm and .aspx  
</Directory>

# For all virtual ASP.NET webs, we need the aspnet_client files  
# to serve the client-side helper scripts.  
AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"

<Directory "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">  
Options FollowSymlinks  
Order allow,deny  
Allow from all  
</Directory> 

</IfModule>  

asp.net

  • Create a directory c:\SampleASP and insert in it the index.aspx
  • Restart apache server :
    Start->Apache HTTP Server 2.0.54 ->
    Control Apache Server -> Restart
  • Open Explorer and navigate to http://localhost/SampleASP/index.aspx
    If everything worked fine you should get a nice asp.net page working.
**— index.aspx —**  
<%@ Page Language="VB" %>   


<link rel="stylesheet"href="intro.css">   


<center>  
<form action="index.aspx" method="post">  
<h3> Name: <input id="Name" type=text>  
Category: <select id="Category" size=1>  
<option>One</option>  
<option>Two</option>  
<option>Three</option>  
</select>  
</h3>  
<input type=submit value="Lookup">  
<p>  
<% Dim I As Integer  
For I = 0 to 7 %>  
<font size="<%=I%>"> Sample ASP.NET TEST</font> <br>  
<% Next %>  
</form>  
</center>  

分类
DotNet

关于使用HASH函数加密

今天在写guestbook的代码的时候,想给密码加密,以前我发过一篇日志,是使用自己的MD5的方法加密的,虽然MD5加密不可逆,但是仍然感觉那个加密方法需要改进一下。

从baidu上搜索了一下HASH后得到MD5加密字符串的范例,特与各位ASP.NET朋友共享一下。

using System;  
using System.Security.Cryptography;  
using System.Text;  
using System.IO;  
using System.Data;  

public string CoumputeHash1(string szToHashString)  
{  

//将 szToHashString转换为字节数组  
byte[] byteToHash = Encoding.Default.GetBytes(szToHashString);  
//创建的 MD5 类的实例  
MD5CryptoServiceProvider csp=new MD5CryptoServiceProvider();  
byte[] byteHashValue = csp.ComputeHash(byteToHash);//计算哈希值  
//将byte数组转化为string  
string szRetHashString=BitConverter.ToString(byteHashValue);  
return szRetHashString;  
}  

public string CoumputeHash2(string szToHashString)  
{  
//将 szToHashString转换为字节数组  
Byte[] byteToHash = Encoding.Default.GetBytes(szToHashString);  

//使用由加密配置系统返回的 MD5 实例创建哈希值  
byte[] byteHashValue = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(byteToHash);  
//将byte数组转化为string  
string szRetHashString=BitConverter.ToString(byteHashValue);  
return szRetHashString;  
}  
分类
DotNet

如何从web.config中取得ConnectionString

通过使用ConfigurationManager,你可以从Web.Config中取得ConnectionString。

Web.Config connectionStrings 配置部分:

<connectionStrings>  
<add name="MyConnectionString" connectionString="Data Source=myDBServer;database=myDB;Integrated Security=True;" providerName="System.Data.SqlClient"/>  
</connectionStrings>  

aspx 文件:

<asp:SqlDataSource ID="DS" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>  

代码中:
C#代码:

string strConnString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;  

VB.NET代码

Dim strConnString As String = ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString  
分类
DotNet

ASP 3.0高级编程

今天偶然发现自己的本子里还有ASP3.0高级编程的教程,现在就提供下载给需要的朋友们,呵呵,下完后留个名呗,好吧?

http://www.live-share.com/files/57386/ASP3_____1-10.rar.html

http://www.live-share.com/files/57394/ASP3_____11-20.rar.html

http://www.live-share.com/files/57404/ASP3_____21-36.rar.html

分类
DotNet

VS2005视频教程之C#应用开发

这是微软MSDN提供的16节课的C#视频教程,非常适合入门学习。通过创建一个具体的解决方案,了解C#,学习C#,非常好。

大小就是180多M,我又重新上传了,大家可以下载学习看看。鄙视一下下东西就跑得人!!!

地址如下:

http://rapidshare.de/files/33947282/C_________.rar.html

文件若30天后无人访问就删除了!!!