ASP.NET 代码安全性:不让别人看到CS源代码

wen_qwfy 2008-01-22 09:16:10
ASP.NET,使用C# 语言,想不要别人看到CS源代码,该怎么办????
我以前是用Java语言的,用Eclipse工具, Java能编译成Class文件,跟页面文件一块放到Web服务器上,
ASP.NET如何实现源代码的不泄露和安全性呢?
...全文
587 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
Jlion8 2012-08-21
  • 打赏
  • 举报
回复
// JavaScript Document
document.getViewportHeight = function(){
if (window.innerHeight!=window.undefined) return window.innerHeight;
if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
if (document.body) return document.body.clientHeight;
return window.undefined;
}
//得到浏览器显示的屏幕宽度
document.getViewportWidth = function(){
if (window.innerWidth!=window.undefined) return window.innerWidth;
if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth;
if (document.body) return document.body.clientWidth;
}
/**
* 遮罩层,组件的显示及隐藏
*/


Shade = {
mask:null,
container:null,
isIE6:null,
init:function(){
//判断浏览器是否是ie6或其以下版本
var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
this.isIE6 = true;
}else{
this.isIE6 = false;
}
//将遮罩层加入body
var popmask = document.createElement('div');
popmask.id = 'mask';
document.body.appendChild(popmask);
this.mask = document.getElementById("mask");

//将组件边框加入body
var popcont = document.createElement('div');
popcont.id = 'popupContainer';
popcont.innerHTML ="<div id='popupInner'>"+
"<div id='popupTitleBar'>"+
"<div id='popupTitle'></div>"+
"<div id='popupControls'>"+
"<img src='/App_Them/images/close.gif' onclick='Shade.hide();' id='popCloseBox' title='关闭'/>" +
"</div></div>"+
"<div id='popupFrame'>dd</div>";
document.body.appendChild(popcont);
this.container = document.getElementById("popupContainer");
},
setMaskSize:function(){
var theBody = document.body;

var fullHeight = document.getViewportHeight();
var fullWidth = document.getViewportWidth();

if (fullHeight > theBody.scrollHeight) {
this.popHeight = fullHeight;
} else {
this.popHeight = theBody.scrollHeight;
}

if (fullWidth > theBody.scrollWidth) {
this.popWidth = fullWidth;
} else {
this.popWidth = theBody.scrollWidth;
}

this.mask.style.height = this.popHeight + "px";
this.mask.style.width = this.popWidth + "px";
},
toCenter:function(conf){
var s = this.container.style;
s.left = (document.getViewportWidth()-conf.width)/2+"px";
s.top = (document.getViewportHeight()-conf.height)/2+"px";
},
show:function(conf){
//初始化
this.init();
//设置遮罩层的长度和宽度
this.setMaskSize()
//设置组件的标题
document.getElementById('popupTitle').innerHTML = conf.title;
//设置组件的长和宽
this.container.style.width = conf.width+"px";
this.container.style.height = conf.height+"px";
var frame = document.getElementById('popupFrame');
frame.style.width = (conf.width -4)+"px";
frame.style.height = (conf.height -31)+"px";
//将组件居中显示
this.toCenter(conf);
//设置组件内容
frame.innerHTML = conf.templete;
},
hide:function(){
//删除遮罩层
document.body.removeChild(this.mask);
//删除组件层
document.body.removeChild(this.container);
document.execCommand('Refresh');
}
}
Jlion8 2012-08-21
  • 打赏
  • 举报
回复
// JavaScript Document
document.getViewportHeight = function(){
if (window.innerHeight!=window.undefined) return window.innerHeight;
if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
if (document.body) return document.body.clientHeight;
return window.undefined;
}
//得到浏览器显示的屏幕宽度
document.getViewportWidth = function(){
if (window.innerWidth!=window.undefined) return window.innerWidth;
if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth;
if (document.body) return document.body.clientWidth;
}
/**
* 遮罩层,组件的显示及隐藏
*/


Shade = {
mask:null,
container:null,
isIE6:null,
init:function(){
//判断浏览器是否是ie6或其以下版本
var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
this.isIE6 = true;
}else{
this.isIE6 = false;
}
//将遮罩层加入body
var popmask = document.createElement('div');
popmask.id = 'mask';
document.body.appendChild(popmask);
this.mask = document.getElementById("mask");

//将组件边框加入body
var popcont = document.createElement('div');
popcont.id = 'popupContainer';
popcont.innerHTML ="<div id='popupInner'>"+
"<div id='popupTitleBar'>"+
"<div id='popupTitle'></div>"+
"<div id='popupControls'>"+
"<img src='/App_Them/images/close.gif' onclick='Shade.hide();' id='popCloseBox' title='关闭'/>" +
"</div></div>"+
"<div id='popupFrame'>dd</div>";
document.body.appendChild(popcont);
this.container = document.getElementById("popupContainer");
},
setMaskSize:function(){
var theBody = document.body;

var fullHeight = document.getViewportHeight();
var fullWidth = document.getViewportWidth();

if (fullHeight > theBody.scrollHeight) {
this.popHeight = fullHeight;
} else {
this.popHeight = theBody.scrollHeight;
}

if (fullWidth > theBody.scrollWidth) {
this.popWidth = fullWidth;
} else {
this.popWidth = theBody.scrollWidth;
}

this.mask.style.height = this.popHeight + "px";
this.mask.style.width = this.popWidth + "px";
},
toCenter:function(conf){
var s = this.container.style;
s.left = (document.getViewportWidth()-conf.width)/2+"px";
s.top = (document.getViewportHeight()-conf.height)/2+"px";
},
show:function(conf){
//初始化
this.init();
//设置遮罩层的长度和宽度
this.setMaskSize()
//设置组件的标题
document.getElementById('popupTitle').innerHTML = conf.title;
//设置组件的长和宽
this.container.style.width = conf.width+"px";
this.container.style.height = conf.height+"px";
var frame = document.getElementById('popupFrame');
frame.style.width = (conf.width -4)+"px";
frame.style.height = (conf.height -31)+"px";
//将组件居中显示
this.toCenter(conf);
//设置组件内容
frame.innerHTML = conf.templete;
},
hide:function(){
//删除遮罩层
document.body.removeChild(this.mask);
//删除组件层
document.body.removeChild(this.container);
document.execCommand('Refresh');
}
}
Jlion8 2012-08-13
  • 打赏
  • 举报
回复
hahgoaehgowgheog e
wen_qwfy 2008-01-23
  • 打赏
  • 举报
回复
谢谢大家,要知道会有这么多回复,就多给点分了,虽然囊肿羞涩...
  • 打赏
  • 举报
回复
好像能将aspx映射为html
wsklt 2008-01-22
  • 打赏
  • 举报
回复
vs2005 直接發布就行了,
love969 2008-01-22
  • 打赏
  • 举报
回复
是中间代码没错,但.Net编译的Dll默认也可以通过工具查看源代码的。
如果你用.Net开发,就不要把源代码看得太重。现在不是讲究源代码共享吗。
如果实在是有商业机密,就混淆一下吧。(Baidu:混淆器)

编译后的Dll需要.Net framework支持。ascx跟aspx文件放在IIS根目录或虚拟目录中, .dll放在Bin下面。
wen_qwfy 2008-01-22
  • 打赏
  • 举报
回复
c#开发的ASP.NET项目,在IIS上部署只需要部署相应的aspx,ascx文件和bin目录下的dll???
FrameWork也不用装,就可以访问网站吗?
通过VS2005开发的Web项目,ascx文件在哪呢?这些文件就是编译的中间代码??
刚入门,多谢。
LutzMark 2008-01-22
  • 打赏
  • 举报
回复
只放aspx文件和编译后的程序集,别人就看不见了
kkai189 2008-01-22
  • 打赏
  • 举报
回复
楼上说的对。
楼主可以编译.cs文件为dll,具体楼上说的很清楚。
wuyi8808 2008-01-22
  • 打赏
  • 举报
回复
编译为.dll文件,放在网站根目录的bin目录下。
upingking 2008-01-22
  • 打赏
  • 举报
回复
呵呵,c#部署只需要部署相应的aspx,ascx文件和bin目录下的dll,aspx.cs文件中的代码都会编译到bin目录下的dll中
java是一个java文件编译一个class文件,.net是一个工程下的.cs文件都编译到bin目录下的dll中
iceblockchina 2008-01-22
  • 打赏
  • 举报
回复
6楼正解
Atai-Lu 2008-01-22
  • 打赏
  • 举报
回复
呃...
java编译成class文件...
C#编译成dll文件...
网站发布之后.cs文件完全可以去掉
xiaoniao_28 2008-01-22
  • 打赏
  • 举报
回复
是中间代码没错,但.Net编译的Dll默认也可以通过工具查看源代码的。
如果你用.Net开发,就不要把源代码看得太重。现在不是讲究源代码共享吗。
如果实在是有商业机密,就混淆一下吧。(Baidu:混淆器)

编译后的Dll需要.Net framework支持。ascx跟aspx文件放在IIS根目录或虚拟目录中, .dll放在Bin下面。

6楼的说的不错/
core77 2008-01-22
  • 打赏
  • 举报
回复
发布网站,自动编译成dll了
yaoshun1983 2008-01-22
  • 打赏
  • 举报
回复
网站发布另存一个文件夹这个问题主解决了。
lovehongyun 2008-01-22
  • 打赏
  • 举报
回复
asp.net的项目发布后也是看不到源代码的.
HarrisonCao 2008-01-22
  • 打赏
  • 举报
回复
可以使用.net framework中的aspnet_compiler工具,使用方法如下。
比如我们现在编译的应用程序,虚拟目录是aspnet,实际物理路径是E:\aspnet,我们编译后的目标路径是E:\www,那么我们只要执行如下命令就可以了:
aspnet_compiler -v /Aspnet -p E:\aspnet E:\www



执行完成后,我们发现E盘下生成了www的目录,里边的子目录App_Code和所有.cs文件都不见了,还有master页及其代码.cs文件也不见了。多了一个bin目录(里边是些.compiled和dll文件)和一个PrecompiledApp.config文件。其实这时候.aspx文件也被编译了,只是它作为一个标记文件还存在,实际上没有任何实质性的内容(我们发现这时候每个aspx文件的内容都是“这是预编译工具生成的标记文件,不应被删除!”,其实删了也无所谓)。

aspnet_compiler是个很不错的工具,用来预编译ASP.NET应用程序。打开Visual Studio 2005命令提示就可以执行了。详细的可以aspner_compiler -?看看帮助。

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧