Asp.net随记 Part 6(122-)

156.淘宝如何跨域获取Cookie分析

http://developer.51cto.com/art/201104/255729.htm

155.IE9网站模式 技术白皮书

http://www.cnblogs.com/chenxizhang/archive/2011/05/04/2036092.html

154.www的网址转向带www的网址,比如把用户输入的baidu.com进行301重定向到www.baidu.com

 http://www.cnblogs.com/tuzhi/archive/2011/12/30/2306884.html

153.怎样才能让您的网站看起来很专业 ?

152.IIS 网站访问发401.3错误

http://jhxk.iteye.com/blog/420515

151.js给textbox赋值,后台取值的问题

150.EF4.1 报错:Unable to load the specified metadata resource

是因为以下数据配置有问题

<add name="DecisionAuthContext" connectionString="metadata=res://*/DecisionAuthModel.DecisionAuth.csdl|res://*/DecisionAuthModel.DecisionAuth.ssdl|res://*/DecisionAuthModel.DecisionAuth.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=10.1.249.38;initial catalog=ProjectDecision;persist security info=True;user id=mqpan;password=123456;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

149.VS2010智能提示修复

通过重新修复安装Visual Studio也可以解决此问题。

方法是从开始->Microsoft Visual Studio 2008->Visual Studio Tools->Visual Studio 2008 命令提示,进入Common7\IDE。

然后输入:devenv.exe/setup /resetuserdata /resetsettings

我是Visual Studio 2008,你用Visual Studio 2010也是类似的。

148..NET中AOP的几种实现方案

http://www.aspxcs.net/HTML/0936543071.html

147.

http://hi.baidu.com/glaivelee/blog/item/0814c8037ace04e309fa9372.html

146.ASP.NET使用Memcached高缓存实例(初级教程)

http://www.xueit.com/html/2009-05/21_2027_00.html

145.XML Web Service并发异步调用的问题及其解决方案

http://archive.cnblogs.com/a/1747812/

144.ASP.Net自动批量生成HTML页面和索引页

http://www.cnblogs.com/tzwhx/archive/2008/05/18/1201815.html

143.  处理【由于 Web 服务器上的“ISAPI 和 CGI 限制”列表设置,无法提供您请求的页面】

http://blog.csdn.net/abandonship/archive/2010/08/24/5834283.aspx

142.关于IE(frameset)导致cookie丢失的问题

   当在frameset结构下引入另一个站点的页面,就会导致cookie丢失,也就同样导致服务端的session会话的丢失(firefox 无此问题),从而使得每次请求都要到SSO服务器去验证大大降低运行效率。查询 MSDN 得知加入Response Header:response.addHeader("P3P","CP=CAO PSA OUR"),就可以解决该问题。

141.C# 双引号替换单引号

root.ToString ().Replace ( "\"" , "'" ).Replace ( "“" , "'" ); 

140.ashx "XML解析错误:未找到元素"

1.如下配置,可以正常使用ajaxpro
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <pages enableViewStateMac="false">
      <namespaces>
        <add namespace="HTWeb.Generic"/>
        <add namespace="Microsoft.Security.Application"/>
      </namespaces>
      <controls>
        <add src="~/UserControls/Pagination.ascx" tagPrefix="ht" tagName="Pagination" />
      </controls>
    </pages>
   <httpHandlers>
       <add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
    </httpHandlers>
  </system.web>

2.如下配置可以正常使用handler.ashx
 <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <pages enableViewStateMac="false">
      <namespaces>
        <add namespace="HTWeb.Generic"/>
        <add namespace="Microsoft.Security.Application"/>
      </namespaces>
      <controls>
        <add src="~/UserControls/Pagination.ascx" tagPrefix="ht" tagName="Pagination" />
      </controls>
    </pages>
   <httpHandlers>
       <add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
    </httpHandlers>
  </system.web>
3.如下配置两者都可以使用
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <pages enableViewStateMac="false">
      <namespaces>
        <add namespace="HTWeb.Generic"/>
        <add namespace="Microsoft.Security.Application"/>
      </namespaces>
      <controls>
        <add src="~/UserControls/Pagination.ascx" tagPrefix="ht" tagName="Pagination" />
      </controls>
    </pages>
   <httpHandlers>
       <add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
    </httpHandlers>
  </system.web>
  <location path="ajaxpro">
    <system.web>
      <httpHandlers>
        <add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
      </httpHandlers>
    </system.web>
  </location>


139.Linq To DataSet 报错:“specified cast is not valid”

 如:Decimal Score;

 //ERROR

Score = hotelList.Field<Decimal> ( " Score " )

//Succeed

Score = Decimal.Parse(hotelList.Field<Double>(“Score”));

138.在Visual Studio 2010中调试DB2

http://www.infoq.com/cn/news/2010/11/DB2-VS2010

137.Javascript下的urlencode编码解码方法encodeURIComponent()\decodeURIComponent()

如:http://XXXXXX/A=ZZZ&U=http://XXXXXX?B=XXXX 
U = encodeURIComponent(http://XXXXXX?B=XXXX )

 http://wo.zdnet.com.cn/space-476979-do-blog-id-3639.html

136.Set DataGridView Selection

http://www.vcskicks.com/datagridview-selection.php

135.禁用Backspace键不让退到上一个网页

http://www.xueit.com/html/show-4548-2.aspx

134.总结JavaScript(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作

http://www.cnblogs.com/ly5201314/archive/2010/06/10/1755606.html

133.Linq To Sql 遇到 Explicit construction of entity type 'XXX.Item' in query is not allowed.”

(不允许在查询中显式构造实体类型)

http://www.cnblogs.com/JeffreyZhao/archive/2008/02/19/using-translate-method-and-modify-command-text-before-query-in-linq-to-sql.html

132.MAC安装 http://www.51ibm.com/thread-156504-1-1.html

VMware Workstation7.1序列号/注册码如下:
CG340-29ZE4-0843P-TFPQ9-YLHV4

131.javascript 父窗口(父页面)— 子窗口 (子页面)互相调用的方法

http://www.javaeye.com/topic/295075

 window.frames["frmTest"].window.OperateOverTime($('#monitor').text());

130.web.config特殊字串配置的问题

WebConfig中HtmlEntity问题

129.DataGridView显示行号的几种方法

http://www.cnblogs.com/BlackBat/archive/2010/02/04/1663445.html

128.安装时 IIS URL Rewrite Module 2报错解决方案

报错信息:

IIS URL Rewrite Module 2 Setup Wizard ended prematurely because of an error.

有可能是因为

  • Program Files 目录权限有问题
  • 添加EveryOne权限
  • 如果安装了ISAPI_Rewrite Manager,也可以设置这个文件夹不只读,并添加EveryOne权限

127.Asp.net让某一页的requestEncoding设置成gb2312的方法

http://www.cnblogs.com/wolanda/archive/2008/07/04/1235813.html

126.XML Serializable Generic Dictionary
http://www.cnblogs.com/shanyou/archive/2006/05/24/408334.html

125.有关于cookie expire time的获取

比如:

我设置一个cookie过期时间
然后我把浏览器closed,再打开, 再去debug
发现cookie的过期时间总是0001-01-01
原因:

Changing a Cookie's Expiration Date
The browser is responsible for managing cookies, and the cookie's expiration time and date help the browser manage its store of cookies. Therefore, although you can read the name and value of a cookie, you cannot read the cookie's expiration date and time. 
When the browser sends cookie information to the server, the browser does not include the expiration information. (The cookie's Expires property always returns a date-time value of zero.) 
http://msdn.microsoft.com/en-us/library/ms178194.aspx

 

124.requestPathInvalidCharacters

如果你想不让ASP.net 替你拦截这些特殊字符,你需要设置如下Web.config的节:

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<httpRuntime requestPathInvalidCharacters="" />
</system.web>
</configuration>

注意其中的requestPathInvalidCharacters 它是一个以逗号分隔的无效字符列表。不设置它时,它默认的无效字符集(以,分割)是后面7个:<,>,*,%,&,:,\

即,不设置这个属性,默认就是如下设置:

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<httpRuntime requestPathInvalidCharacters="&lt;,&gt;,*,%,:,&amp;,\" />
</system.web>
</configuration>

如果你想这些字符全部不受限制,就应该设置 requestPathInvalidCharacters="" , 如果是部分字符受限制,部分字符不受限制,就需要在 requestPathInvalidCharacters 中设置需要受限制的字符,不受限制的不用设置。

123.The request was aborted: The request was canceled.

Global.asax

void Application_Start (object sender , EventArgs e) {

       //设置服务idleTime

       System.Net.ServicePointManager.MaxServicePointIdleTime = 4000;

}

参考资料:http://shanny.ycool.com/post.2657862.html

122.又遇IIS 7不能压缩js文件的问题

http://www.cnblogs.com/dudu/archive/2010/03/25/1696180.html

Asp.net 随记 Part5 (91-121 )

Asp.net 随记 Part4 (71-90 )

Asp.net 随记 Part3 (53- 70)

Asp.net 随记 Part2 (31- 49)

Asp.net 随记 Part1 (1- 30)

代码
1.如下配置,可以正常使用ajaxpro
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<pages enableViewStateMac="false">
<namespaces>
<add namespace="HTWeb.Generic"/>
<add namespace="Microsoft.Security.Application"/>
</namespaces>
<controls>
<add src="~/UserControls/Pagination.ascx" tagPrefix="ht" tagName="Pagination"/>
</controls>
</pages>
<httpHandlers>
<add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
</httpHandlers>
</system.web>

2.如下配置可以正常使用handler.ashx
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<pages enableViewStateMac="false">
<namespaces>
<add namespace="HTWeb.Generic"/>
<add namespace="Microsoft.Security.Application"/>
</namespaces>
<controls>
<add src="~/UserControls/Pagination.ascx" tagPrefix="ht" tagName="Pagination"/>
</controls>
</pages>
<httpHandlers>
<add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
</httpHandlers>
</system.web>
3.如下配置两者都可以使用
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<pages enableViewStateMac="false">
<namespaces>
<add namespace="HTWeb.Generic"/>
<add namespace="Microsoft.Security.Application"/>
</namespaces>
<controls>
<add src="~/UserControls/Pagination.ascx" tagPrefix="ht" tagName="Pagination"/>
</controls>
</pages>
<httpHandlers>
<add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
</httpHandlers>
</system.web>
<location path="ajaxpro">
<system.web>
<httpHandlers>
<add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
</httpHandlers>
</system.web>
</location>

posted @ 2010-07-15 21:37  RicoRui  阅读(1926)  评论(4编辑  收藏  举报