按 ‘ Asp.net ’ 标签归档

windows 2008+VS2008+NOD32无法调试aspx文件的解决方法.

记得以前在windows2008+vs2008+nod32这样的配置下出现无法调试aspx时只要在NOD32的高级设置–病毒和间谍软件防护–协议过滤的重定向以下对象的网络通信以进行检查,选择HTTP和POP3端口即可了,后来每次重装系统时安装完NOD32都这样设置一下。

今天在使用VS时发现不能调试了,搞的我一头雾水,检查一下NOD32的配置感觉也没什么问题,尝试http://127.0.0.1:端口这样可以访问,于是把localhost也加入到NOD32WEB访问白名单里,还是不行,GOOGLE一下,有人说了在NOD32中“Web 访问保护 -> HTTP”上,把“启用HTTP检查”关闭掉,呵呵,不管用,重要的是这样做当你访问HTTP时就不检查了,要注意安全啊…

Google到了,只要删除C:\Windows\System32\drivers\etc\hosts里下面一行注释掉就没问题了。
# ::1             localhost

这一行有什么作用呢?下面的内容出自维基百科:

在计算机网络中,localhost(意为“这台计算机”)是给回路网络接口的一个标准主机名。这个名称也是一个保留域名(RFC 2606) (参见.localhost),为了避免同狭义定义主机名混淆而单独列出。

在不使用计算机的主机名称的地方指定为localhost。[1]例如,将web服务器上安装的web浏览器指向http://localhost,将会显示运行这个浏览器的计算机上所服务的网站的主页,但是只有当web服务器配置至服务回路接口。

localhost always translates to the loopback IP address 127.0.0.1 in IPv4, or ::1 in IPv6 (see below).[2]

Communicating with the loopback interface in an identical manner as with a remote computer, but bypassing the local network interface hardware, is useful for the purposes of testing software. Connecting to locally hosted network services (such as game servers) or for other inter-process communications can be performed through localhost addresses in a highly efficient manner.

For example, a common basic test of the TCP/IP protocol stack on a computer is to use the ‘ping’ command at the operating system’s command line prompt:

ping localhost

IETF document “Special-Use IPv4 Addresses” (RFC 3330) describes the IPv4 address block 127.0.0.0/8 as being reserved for loopback. It is therefore excluded from assignment by a Regional Internet Registry or IANA.

For IPv4 communications, the virtual loopback interface of a computer system is normally assigned the address ’127.0.0.1′ with subnetwork mask ’255.0.0.0′. Depending on the specific operating system in use (notably in Linux), and the routing mechanisms installed, this often populates the routing table of the local system with an entry so that packets destined to any address from the ’127.0.0.0/8′ block would be routed internally to the network loopback device.

In IPv6, on the other hand, the loopback routing prefix ::1/128 consists of only one address ::1 (i.e., 0:0:0:0:0:0:0:1, the address with a one at its least significant bit and zero otherwise) is explicitly defined as an automatic loopback address (RFC 4291), though additional addresses may be assigned to the loopback interface by the host administrator.

Any IP datagram with a source or destination address set to a localhost address must not appear outside of a computing system, or be routed by any routing device. Packets received on an interface with destination address of ‘localhost’ must be dropped.

One notable exception to the use of the 127/8 network addresses is their use in Multiprotocol Label Switching (MPLS) traceroute error detection techniques (RFC 4379) in which their property of not being routable provides a convenient means to avoid delivery of faulty packet to end users.

 

在虚拟主机上部署asp.net membership

由于asp.net membership默认使用dbo用户访问数据哭,所以在将memebership部署到虚拟主机上通常会出项数据库无法访问,造成memebership无法正常使用,下面就如何解决这一问题分享一些个人的经验,避免大家再走弯路:

1、在虚拟主机上建立memebership数据库时(基本虚拟主机sql server数据库都不会提供dbo用户),将membership数据库的sql脚本中所有[dbo].和dbo.去除,这样在建立membership数据库时,所有对象将使用当前连接用户创建。

2、到microsoft下载membership源码,地址:http://download.microsoft.com/download/a/b/3/ab3c284b-dc9a-473d-b7e3-33bacfcc8e98/ProviderToolkitSamples.msi,默认安装(推荐)后可以在C:\Program Files\ASP.NET Provider Toolkit SQL Samples下找到源项目,将该项目添加到你的解决方案中,并且在需要使用的项目中引用该项目。

3、重写membership,将memebership项目中所有源代码中的dbo.去除,重新生成membership项目,这时在你的项目的bin目录下将生成一个ProviderToolkitSampleProviders.dll文件。

4、位置web.config文件中的membership节如下:
<membership>
      <providers>
        <clear/>
        <add
          connectionStringName=”MyMemeberShipConnectionString”
          enablePasswordRetrieval=”false”
          enablePasswordReset=”true”
          requiresQuestionAndAnswer=”false”
          applicationName=”/”
          requiresUniqueEmail=”true”
          passwordFormat=”Hashed”
          maxInvalidPasswordAttempts=”5″
          minRequiredPasswordLength=”4″
          minRequiredNonalphanumericCharacters=”0″
          passwordAttemptWindow=”10″
          passwordStrengthRegularExpression=”"
          name=”AspNetSqlMembershipProvider”
          type=”Microsoft.Samples.SqlMembershipProvider”/>
      </providers>
    </membership>

如果使用了webpart,web.config文件中webpart节配置如下:
    <webParts>
      <personalization>
        <providers>
          <remove name=”AspNetSqlPersonalizationProvider”/>
          <add
            connectionStringName=”WebScheduleConnectionString”
            name=”AspNetSqlPersonalizationProvider”
            type=”Microsoft.Samples.SqlPersonalizationProvider”/>
        </providers>
      </personalization>
    </webParts>

大功告成,希望microsoft在下一个membership版本中可以改进一下,不要再强迫大家使用dbo用户了。

Page 1 of 11