Wednesday 10 December 2008

ZT ASP.NET Web Site Layout

删节版本,原文太罗嗦

You can keep your Web site's files in any folder structure that is convenient for your application. To make it easier to work with your application, ASP.NET reserves certain file and folder names that you can use for specific types of content.

Default Pages

The default page is the page that is served when users navigate to your site without specifying a particular page. In IIS, default pages are established as properties of your Web site.

Application Folders

ASP.NET recognizes certain folder names that you can use for specific types of content. The table below lists the reserved folder names and the type of files that the folders typically contain.

Note: The content of application folders, except for the App_Themes folder, is not served in response to Web requests, but it can be accessed from application code.
Folder Description

App_Browsers

Contains browser definitions (.browser files) that ASP.NET uses to identify individual browsers and determine their capabilities. For more information, see Browser Definition File Schema (browsers Element) and How to: Detect Browser Types in ASP.NET Web Pages.

App_Code

Contains source code for utility classes and business objects (for example, .cs, .vb, and .jsl files) that you want to compile as part of your application. In a dynamically compiled application, ASP.NET compiles the code in the App_Code folder on the initial request to your application. Items in this folder are then recompiled when any changes are detected.

Note:Arbitrary file types can be placed in the App_Code folder to create strongly typed objects. For example, placing Web service files (.wsdl and .xsd files) in the App_Code folder creates strongly typed proxies.

Code in the App_Code folder is referenced automatically in your application. In addition, the App_Code folder can contain subdirectories of files that need to be compiled at run time. For more information, see Shared Code Folders in ASP.NET Web Sites and codeSubDirectories Element for compilation (ASP.NET Settings Schema).

App_Data

Contains application data files including MDF files, XML files, as well as other data store files. The App_Data folder is used by ASP.NET 2.0 to store an application's local database, which can be used for maintaining membership and role information. For more information, see Introduction to Membership and Understanding Role Management.

App_GlobalResources

Contains resources (.resx and .resources files) that are compiled into assemblies with global scope. Resources in the App_GlobalResources folder are strongly typed and can be accessed programmatically. For more information, see ASP.NET Web Page Resources Overview.

App_LocalResources

Contains resources (.resx and .resources files) that are associated with a specific page, user control, or master page in an application For more information, see ASP.NET Web Page Resources Overview.

App_Themes

Contains a collection of files (.skin and .css files, as well as image files and generic resources) that define the appearance of ASP.NET Web pages and controls. For more information, see ASP.NET Themes and Skins Overview.

App_WebReferences

Contains reference contract files (.wsdl files), schemas (.xsd files), and discovery document files (.disco and .discomap files) defining a Web reference for use in an application. For more information about generating code for XML Web services, see Web Services Description Language Tool (Wsdl.exe).

Bin

Contains compiled assemblies (.dll files) for controls, components, or other code that you want to reference in your application. Any classes represented by code in the Bin folder are automatically referenced in your application. For more information, see Shared Code Folders in ASP.NET Web Sites.

Managing Subfolders

Configuration settings for your site are managed in a Web.config file that is located in the site's root folder. If you have files in subfolders, you can maintain separate configuration settings for those files by creating a Web.config file in that folder.
Note:

You cannot set or override configuration settings at the subfolder level if they apply to the site as a whole.

ZT CSS Issue总结

ZT, 我遇到的问题是有IIRF导致的。:) 可以再加一条。

经常有人遇到ASP.NET 2.0(ASP.NET 1.x中可能是有效的)中CSS失效的问题,现将主要原因和解决方法罗列如下:

1,CSS文件路径不正确
这个问题属于Web开发中的基础问题,一般采用相对路径会出现这样的问题,或者样式文件写在了母版页里面,在内容页与母版页不在同一级目录下时会出现这样的问题。此时你要清楚Web中相对路径的规则,如果你不清楚,可以采用绝对路径的写法试试就知道是不是路径的问题了。

2,CSS规则写法错误
这个问题谁也帮不你,只能自己学习CSS的相关知识了。

3,文件编码问题
有时候,CSS样式放在aspx文件里有效,而放在独立的文件中无效,这样的问题如果不是路径问题,则就是编码问题造成的,可以将CSS文件用记事本打开,再另存为ANSI格式或者UTF-8格式即可。

4,权限问题
这种情况常见的现象是登录之前样式无效,登录之后才有效,这是典型的权限问题造成的。由于web.config配置了所有文件不允许匿名访问,才会出现这样的问题,解决方法就是将标记将样式文件配置为允许匿名访问。例如:
引用内容










5,单击按钮样式失效
这种情况最典型的原因是单击按钮事件里有类似Response.Write这样的语句,由于ASP.NET 2.0默认采用http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd文档类型定义,它就要求在的前面不能有任何输出。这种问题的解决方法是采用ClientScriptManager输出,或者采用Literal控件输出内容。

6,在ASP.NET 1.x里面起作用的样式到ASP.NET 2.0里面失效
这种问题一般仍然是xhtml1造成的,由于http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd的样式规则与以前的不同,如要加单位,例如width:200;现在要写成width:200px;这种问题的解决方法就是要明确加上单位。

7,脚本设置的样式无效
由于xhtml1.DTD要求有单位,因此在设置对象样式的数值时,仍然要加上单位,如obj.style.width = "200px"。下面的代码在Firefox了是无效的(不要抱怨Firefox麻烦)

引用内容





测试



!-->

尽管上面在IE中正常,但在Firefox里面则会出现问题。正确写法为

引用内容
document.getElementById("x").style.height="200px"

SQL Server Login error

无法连接到服务器
服务器:消息18452, 级别16,状态1
[Microsoft][ODBC SQL Server Driver][SQL Server]用户‘sa’登陆失败。原因:未与信任SQL Server连接相关联
该错误产生的原因是由于SQL Server使用了"仅 Windows"的身份验证方式,因此用户无法使用SQL Server的登录帐户(例如 sa )进行连接,解决方法如下

设置允许SQL Server身份登录
操作步骤:
  1. 在企业管理器中,展开"SQL Server组",鼠标右键点击SQL Server服务器的名称
  2. 选择"属性"
  3. 再选择"安全性"选项卡
  4. 在"身份验证"下,选择"SQL Server和 Windows"
  5. 确定,并重新启动SQL Server服务。

IIS 6.0 学习

玩了几天的IIS,深感没有Tomcat不方便,一堆一堆的菜单,看着就郁闷。郁闷的原因是缺少一份像Tomcat的配置文件,容易管理,容易复制。

不管咋样,工作归工作,学习资料和遇到的困难记录如下。

Windows 03 安装和配置IIS
  1. 安装:首先我们将windows2003系统安装光盘放入光驱中。依次在电脑右下角,单击开始 → 控制面板 →选择填加删除程序 填加/删除windows组件→应用程序服务器,点击安装。
  2. 配置:
    • 开启asp访问父路径。 单击 网站 → 属性 → 主目录 → 配置 → 选项 → 启用父路径
    • 开启asp访问权限。 步骤如下:打开internet信息服务器管理器 。选中Web服务扩展。选中右侧Active Server Pages ,单击 允许。
    • 用非Admin域登录,然后以Admin的权限启动IIS。runas /user:Administrator "mmc c:\windows\system32\inetsrv\iis.msc"
  3. SMTP安装:
    1. 同安装IIS,略。
    2. 配置:
      • 用ADMIN权限启动IIS,同IIS。
      • Right Click Default SMTP Virtual Server ? Properties ? Access ? Relay,设置可以使用SMTP的机器的IP
遇到的问题以及解决方法

找回IUSR_***密码
  • Adsutil.vbs脚本位于C:\Inetpub\AdminScripts. 打开CMD,进入C:\Inetpub\AdminScripts目录 执行下面的语法:
  • 功能语法
    • 获取 IUSR 帐户密码 cscript.exe adsutil.vbs get w3svc/anonymoususerpass
    • 获取 IWAM 帐户密码 cscript.exe adsutil.vbs get w3svc/wamuserpass
    • 设置 IUSR 帐户密码 cscript.exe adsutil.vbs set w3svc/anonymoususerpass "password"
    • 设置 IWAM 帐户密码 cscript.exe adsutil.vbs set w3svc/wamuserpass "password"
  • 备注:如果密码不是明文密码,必须修改 Adsutil.vbs,使它显示明码。为此,请按照下列步骤操作:
    1. 在记事本中打开 Adsutil.vbs。
    2. 在"编辑"菜单上,单击查找,键入 IsSecureProperty = True,然后单击查找下一个。
    3. 将"IsSecureProperty = True"更改为"IsSecureProperty = False"。
    4. 保存对 Adsutil.vbs 所做的更改,然后关闭记事本。
403 Error
  • Errpr Description:403 You have attempted to execute a CGI, ISAPI, or other executable program from a directory that does not allow programs to be executed. This happens live on the web and locally on the server.
  • Solution:sound to me like either you need to check the Execute Permissions on the Web
    Site.
    • Open Internet Information Services MMC
    • Select the web site right click and select properties go to the Home Directory tab
    • Check the "Execute Permissions".Sounds like it is set to NONE
SMTP RCPT 550
  • Error Description: Could not send out email. SMTP Log shows 550 failed.
  • Solution:Check authentication, either IP and user/password.
"Directory Listing Denied"
  • Error Description: Directory Listing Denied This Virtual Directory does not allow contents to be listed.
  • Potional Solution:只配了虚拟目录,没有设置默认文档造成的.解决问题的方案:
    • 打开IIS->属性->文档标签页->设置你们网站默认主页。
ReDirect Page Issue
  • Error Description:用外围IP浏览,发现所有的CSS式样,主页都不见,全部redirect到一个页面上去了。但是用localhost就一切正常。
  • Solution:卸掉在IIS上的某web site上配置的IIRF(redirect配置程序)以后,发现还是如此,后来发现是在website的全站级别上又配置了一层IIRF,导致错误的redirect。
  • 可以继续深入的问题:
    • 为什么用localhost就不会加载全站级别的配置?或者说,localhost下全局配置无效?
浏览网站的时候会弹出来用户名密码
  • Error Description:浏览网站的时候会弹出来用户名密码,在IIS里面配置的也是用IUSR_***用户名来访问的。
  • Solution:IIS设置的时候将用密码输错了,需要让系统和设置的密码一致。取得密码可以使用上面的Adsutil.vbs工具,再重新设置IIS的匿名访问权限。
Parser Error Message: Unrecognized attribute 'xmlns'.
  • ErrorDescription:When I run the webpage from the server it works without a problem. But if I try running the webpage from a remote box the first screen works, but clicking a hyperlink on the first page shows this error: Server Error in '/' Application. Configuration Error
    • Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
    • Parser Error Message: Unrecognized attribute 'xmlns'.
    • Source Error:
    • Line 1:
    • Line 2:
    • Line 3:
    • Source File: c:\inetpub\wwwroot\TESTPORTAL05\web.config Line: 2
  • Solution:
    1. virtual directory was set up for v1.1 of the .Net framework, the solution was simple: go to the properties page for the application in IIS, pick the "Asp.net" tab, and change the target framework to 2.0.
    2. 先装IIS后装ASP.net也会这样。Enter start, program, visual studio 2005 beta 2, visual studio tools, visual studio 2005 command prompt. Type the command "aspnet_regiis -i"

无法显示 XML 页。字符开头。

  • Error Description: 处理资源 'http://localhost/Lanxum/default.aspx' 时出错。
    • 第 1 行,位置: 2
    • Fire Fox: XML解析错误:未组织好位置:http: //localhost/Lanxum/dTeam.aspx 行:1,列:2<%@ page language="C#" masterpagefile="~/MasterPage.master" autoeventwireup="true" inherits="dTeam, App_Web_hkuu-y0n" title="Untitled Page" theme="iAffron" stylesheettheme="iAffron" %> -^
    • IE, error reported as below:
    • I use visual studio 2005 and iis to develope a new .net website. I promise the code is right, but most pages running in Firefox 2.0 reported this error:
  • Solution : The reason is that I install visual studio first(together with .net framework 2.0) and then install IIS. It made .net FK didn't register in IIS. Just run this command with DOS:
    • C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i
    • Once if you have install .net FK and IIS correctly, this sentence will follow:
    • 开始安装 ASP.NET 。........................................
    • ASP.NET 安装完毕
    • Then refresh the page, you will find that the problem is fixed.

Don't make me think

原则:Don't make me think

三次无须思考,明确无误的点击相当于一次需要思考的点击。

广告牌设计101法则
  • 建立清楚的视觉层次
    • 越重要的地方要越突出
    • 逻辑相关的地方在视觉上也要相关
    • 逻辑上包含的部分在视觉上进行嵌套
  • 尽量利用习惯用法
  • 把页面划分成明确定义的区域
  • 明显标识可以点击的地方
  • 最大限度降低干扰
    • 眼花缭乱
    • 先假定所有内容都是视觉噪声,除非得到证明它们不是
省略不必要的文字--不要在Web上写作的艺术
  • 省略多余的文字
  • 欢迎词必须被消灭
  • 指示说明必须被消灭
网站导航101法则
  • 通常为了寻找某个目标
  • 你会决定先询问还是先浏览
  • 如果选择浏览,你将通过标志的引导在层次结构中穿行
  • 最后,如果找不到想要的东西,你会离开

Don't make me think

原则:Don't make me think

三次无须思考,明确无误的点击相当于一次需要思考的点击。

广告牌设计101法则
  • 建立清楚的视觉层次
    • 越重要的地方要越突出
    • 逻辑相关的地方在视觉上也要相关
    • 逻辑上包含的部分在视觉上进行嵌套
  • 尽量利用习惯用法
  • 把页面划分成明确定义的区域
  • 明显标识可以点击的地方
  • 最大限度降低干扰
    • 眼花缭乱
    • 先假定所有内容都是视觉噪声,除非得到证明它们不是
省略不必要的文字--不要在Web上写作的艺术
  • 省略多余的文字
  • 欢迎词必须被消灭
  • 指示说明必须被消灭
网站导航101法则
  • 通常为了寻找某个目标
  • 你会决定先询问还是先浏览
  • 如果选择浏览,你将通过标志的引导在层次结构中穿行
  • 最后,如果找不到想要的东西,你会离开