ASP.NEt 4.0问题 [英] ASP.NEt 4.0 questions

查看:62
本文介绍了ASP.NEt 4.0问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

0)创建班级时,不会自动为我创建App_Code文件夹.

1)我编写了一个从System.Web.UI.Page继承的BasePage类.当我输入时,intellisense不会像我以前那样改变Page的颜色(但是也没有带下划线来表示错误).

2)当我尝试在网站的其他地方使用BasePage类时,它表示当我尝试在浏览器中查看页面时找不到它.

这是因为我在做一个Web应用程序而不是一个网站吗?如果是这样,我该如何解决?我曾尝试将基本页面类移至根站点文件夹,但这根本无济于事.

编辑==============

我还忘了提到,当我创建基本页面类时,必须在文件顶部添加using System.Web.UI;,但要添加intellisense.

另外(这是个大问题),我创建了一个新的网站(与Web应用程序相对),而我上面描述的所有问题都消失了.为什么会有所不同?

0) When I create a class, the App_Code folder isn''t automagically created for me.

1) I''ve written a BasePage class that inherits from System.Web.UI.Page. When I type that out, intellisense doesn''t change the color of Page like I''m used to (but it''s not underlinedeither to indicate an error).

2) When I try to use the BasePage class elsewhere in the site, it says it can''t find it when I try to view a page in the browser.

Is this all happening because I''m doing a web app versus a web site? If so, how can I fix it? I''ve tried moving the base page class to the root site folder, and that didn''t help at all.

EDIT ==============

I also forgot to mention that when I created the base page classes, I had to add using System.Web.UI; to the tops of the files, but intellisense.

Also (and this is the big one) I created a new web site (as opposed to a web app), and all of the problems I described above disappeared. Why does it make a difference?

推荐答案

约翰,
对于Web应用程序,没有预定义的文件夹来保存代码.您可以直接添加类,但这不是好方法.因此,您可以添加一个新文件夹(任何名称).添加App_Code文件夹后,其中的类可能具有类似Your application name.your folder name的名称空间.因此,您必须访问App_code.your class name之类的类.否则,从名称空间中删除文件夹名称,就可以直接访问这些类.

希望对您有所帮助.
Hi John,
For a web application there is no predefined folder to keep the codes. Either you can directly add the classes, that is not the good way. So you can add a new folder (any name). As you are added the App_Code folder, the classes inside may have the namespace like Your application name.your folder name . So you have to access the classes like App_code.your class name. Else remove the folder name from the namespace, you can access the classes directly.

Hope this helps.


0)创建类时,并不是为我自动创建App_Code文件夹.
第一次仅将类添加到根目录时,它应要求您将其放置在App_Code文件夹中.如果不存在,它将创建一个.如果您没有遇到这种情况,请尝试手动创建文件夹,然后将类文件放在此处. (一旦创建了文件夹,它的颜色就会自动更改为其他颜色,然后变为常规的文件夹颜色.)

1)我编写了一个继承自System.Web.UI.Page的BasePage类.当我输入时,intellisense不会像我以前那样改变Page的颜色(但是也没有带下划线来表示错误).

2)当我尝试在网站上的其他地方使用BasePage类时,它表示当我尝试在浏览器中查看页面时找不到它.
看起来配置不正确.它应该更改颜色并提供访问权限.如果到目前为止尚未尝试,请在App_Code中尝试使用BasePage.我真的怀疑应该是因为WebApp&网站差异.

如果在尝试使用App_Code文件夹后仍然遇到问题,请分享您的意见,我想重复一下&将其复制到我的系统上.
0) When I create a class, the App_Code folder isn''t automagically created for me.
When you add just a class to the root for the first time, it should ask you to place it in App_Code folder. If it does not exists, it creates one. In case this has not happened with you then, try creating the folder manually and place the class file there. (Once you create the folder, it''s color would automatically change to some other color then a general folder color.)

1) I''ve written a BasePage class that inherits from System.Web.UI.Page. When I type that out, intellisense doesn''t change the color of Page like I''m used to (but it''s not underlinedeither to indicate an error).

2) When I try to use the BasePage class elsewhere in the site, it says it can''t find it when I try to view a page in the browser.
Looks like it did not configure correctly. It should change color and give access. Try with BasePage in App_Code if not done till now. I really doubt it should be because of WebApp & Website difference.

If after trying with App_Code folder, you are still facing the issue, do share across your observations, I would like to repeat & replicate it on my system.


John,您好-您是否记得更新过web.config?
Hi John - did you remember to update your web.config?
<compilation debug="false">
    <codeSubDirectories>
        <add directoryName="VBCode" />
        <add directoryName="CSCode" />
    </codeSubDirectories>
</compilation>



在此处查找更多信息 [



Look here for more info[^]

It''s just a thought :-D

Graciously, yours truly,
Espen Harlinn


这篇关于ASP.NEt 4.0问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆