如何在Web应用程序中定义全局类? [英] How Can I Define Global Classes In Web Application ?
问题描述
如何在Web应用程序中定义全局类?
可以将类设置为会话变量吗?
谢谢
How can I define global classes in web application ?
Classes can be set to session variables ?
Thanks
推荐答案
在App_Code文件夹中创建您的类,您可以在会话中存储任何对象。
问候
Prakash.V
" Sylvia A." < sl **** @ ccc.com写信息
新闻:eI ************** @ TK2MSFTNGP03.phx.gbl ...
Create your class in App_Code folder, you can store any objects in session.
Regards
Prakash.V
"Sylvia A." <sl****@ccc.comwrote in message
news:eI**************@TK2MSFTNGP03.phx.gbl...
如何在Web应用程序中定义全局类?
可以将类设置为会话变量吗?
>
谢谢
How can I define global classes in web application ?
Classes can be set to session variables ?
Thanks
rea:
rea:
如何在Web应用程序中定义全局类?
How can I define global classes in web application ?
1.您可以将源代码放在App_Code目录中。
您放置的任何源文件都将被编译。
2.您可以自己编译它们并将生成的
程序集/程序集放在/ bin目录中。
保护您的源代码更多。
要编译单个源代码文件,请使用:
csc / t:library / out:utils .dll utils.cs
要将目录中的所有.cs文件编译为utils.dll,
使用:csc / t:library / out:utils .dll * .cs
如果需要引用.Net Framework程序集或程序集,
添加它们,用斜杠分隔:
csc / t:library /r:system.dll /r:system.data.dll /out:utils.dll * .cs
如果你' '使用VB.NET代替C#,
使用vbc和以.vb结尾的源文件
而不是使用以.cs结尾的csc和源文件。
语法对于vb和c#是相同的。
编译程序集后,将其放在应用程序的/ bin
目录中,然后导入命名空间:
<%@ Import Namespace =" YourNamespace" %>
如果您正在严格使用VS.NET,请按照描述编译您的程序集
并在VS中添加对它的引用。 NET项目。
这将允许您在编码时使用Intellisense并获得
汇编的属性,方法等。
re:
1. You can place source code in the App_Code directory.
Any source files you place there will be compiled.
2. You can compile them yourself and place the generated
assembly/assemblies in the /bin directory.
That protects your source code a bit more.
To compile a single source code file, use :
csc /t:library /out:utils.dll utils.cs
To compile all .cs files in a directory to utils.dll ,
use : csc /t:library /out:utils.dll *.cs
If you need to reference a .Net Framework assembly or assemblies,
add them, separated by slashes :
csc /t:library /r:system.dll /r:system.data.dll /out:utils.dll *.cs
If you''re using VB.NET instead of C#,
use vbc and source files ending in .vb
instead of using csc and source files ending in .cs.
The syntax is the same for vb and c#.
Once you have compiled your assembly, place it in the /bin
directory of your application, and import the Namespace :
<%@ Import Namespace="YourNamespace" %>
If you''re working strictly with VS.NET, compile your assembly
as described and add a reference to it in your VS.NET project.
That will allow you to use Intellisense and get your
assembly''s properties, methods, etc. when coding.
re:
类可以设置为会话变量吗?
Classes can be set to session variables ?
如果你的意思是使用类来设置*会话变量,是的。
Juan T. Llibre,asp.net MVP
asp.net faq: http: //asp.net.do/faq/
foros de asp.net,en espa?ol: http://asp.net.do/foros/
============== =====================
" Sylvia A." < sl **** @ ccc.com在消息新闻中写道:eI ************** @ TK2MSFTNGP03.phx.gbl ...
If you mean to use classes to *set* session variables, yes.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"Sylvia A." <sl****@ccc.comwrote in message news:eI**************@TK2MSFTNGP03.phx.gbl...
如何在Web应用程序中定义全局类?
How can I define global classes in web application ?
可以将类设置为会话变量吗?
Classes can be set to session variables ?
谢谢
Thanks
在Session isn中存储ref类型不建议但是你去吧。
//创建它
myObject myObjectInstance = new myObject();
....在这里工作......
//将其转储到会话中
Session [" myObject"] = myObjectInstance;
//拉回会话
myObject myObjectInstance =(myObject)Session [" myObject"];
我会存储重新生成对象所需的信息,而且它是'b $ b状态而不是将对象存储在Session中。
On 4月12日上午8:33,Sylvia A. < sly ... @ ccc.comwrote:
Storing ref types in Session isn''t advisable but here you go.
//create it
myObject myObjectInstance = new myObject();
....do work here...
//dump it into session
Session["myObject"] = myObjectInstance;
//pull it back out of session
myObject myObjectInstance = (myObject)Session["myObject"];
I would store the information needed to re-produce the object and it''s
state rather than store the object in Session.
On Apr 12, 8:33 am, "Sylvia A." <sly...@ccc.comwrote:
如何在Web应用程序中定义全局类?
类
谢谢
How can I define global classes in web application ?
Classes can be set to session variables ?
Thanks
这篇关于如何在Web应用程序中定义全局类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!