ASP.NET 网站发布与复制? [英] ASP.NET WebSite Publishing vs. Copying?

查看:24
本文介绍了ASP.NET 网站发布与复制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在发布时遇到了很多问题,例如当您需要对代码进行小的更改时,有时需要对生成的 DLL 文件(例如 default.aspx.CS 发布时的 dll 文件)进行更改) 不能被 IIS 识别,说代码隐藏是错误的.抱歉没有记住确切的错误信息.我希望你现在明白我的意思.

I have faced a lot of issues with Publishing like when you need to make small changes on the code, sometimes the generated DLL file (the dll file for example of default.aspx.CS when published) cannot be recognized by IIS saying the codebehind is wrong or something. Sorry for not remembering the exact error message. I am hoping you know what I mean at this point.

因此,我通常会做一个简单的Copy Paste操作而不是Publishing.

Therefore, I usually do a simple Copy Paste operation instead of Publishing.

你能告诉我不使用 Publish 方法我遗漏了什么吗?出版如何更好?或者你更喜欢哪一个,为什么?

Could you tell me what am I missing by NOT using the Publish method? How is Publishing better? Or which one do you prefer, why?

基本上它是一种利弊.

谢谢

推荐答案

好吧,这取决于您所说的复制"是什么意思:

Well, it depends on what you mean by "copy":

通过发布,您可以选择预编译您的应用程序的全部或部分.您可以发布到文件系统(而不是目标/主机)中的本地文件夹,然后复制更新的文件(仅限).如果您要进行代码隐藏"(c#/vb 代码)更改,这意味着您可能只需要复制"/覆盖 dlls.不用说,如果您进行了内容"更改(html/razor/script/etc)更改,那么您也需要复制/覆盖这些更改.

With Publishing you have options to pre-compile all or part of your application. You can publish to a local folder in your file system (instead of your target/host) and then copy the updated file(s) (only). If you are making "code behind" (c#/vb code) changes, this means you'll likely only need to "copy"/overwrite dlls. Goes without saying that if you've made "content" changes (html/razor/script/etc) changes, then you'd need to copy/overwrite those as well.

如果您不熟悉部署,您可能会发现自己只需复制/覆盖所有内容"这是最安全的方法.获得更多经验后,您将识别"哪些资产只需要更新(一个或几个dll 和/或内容代码,而不是所有内容").这没有什么神奇之处,通常,只需在您发布(本地)或重建您的Web应用程序后查看dll/文件的时间戳.

If you're new to deployment, you may find yourself simply copying/overwriting "everything" which is the safest way to go. Once you get more experience, you'll "recognize" which assets you only need to update (one or a few dlls and or content code, instead of "everything"). There's no magic to this, usually, its a matter of just looking at the timestamp of the dll/file after you've published (locally) or rebuild your web application.

我建议做一个local publish,这样你就可以看到你的服务器上实际需要什么.发布到本地文件系统/文件夹的文件是主机/服务器上需要的文件.这样做将可视化并消除发布中的任何谜团":

I'd recommend doing a local publish so you can see what is actually needed on your server. The files published to your local file system/folder is what needs to be on your host/server. Doing so will visualize and remove whatever "mystery" there is to Publishing:

  • 您会看到实际需要的(在您的服务器上)与不需要的
  • 您会看到文件时间戳,这将帮助您识别哪些文件实际发生了更改,哪些文件没有更改(因此不需要更新).
  • 一旦掌握了窍门,您就无需复制"/ftp所有内容",只需更新实际修改过的文件(仅).

因此复制"可以表示上述内容,或者如果您说您将简单地将所有开发代码(原始 (vb/cs)html/cs/vb)复制到您的主机,那么这意味着您的网站将被动态编译,因为需要/请求每个资源(没有什么是预编译).同样简单",但您确实丢失了预编译,这意味着在请求/需要您的每个网页时存在延迟(ASP.net 需要动态编译).此外,您还将在服务器上公开源代码.根据您的情况,这可能没有多大意义,但这是另一件需要考虑的事情.

So "copy" can mean the above, or if you are saying you will simply copy all of your development code (raw (vb/cs)html/cs/vb) to your host, then that means your site will be dynamically compiled as each resource is needed/requested (nothing is pre-compiled). Also "easy" but you do lose pre-compilation which means there is a delay when each of your web pages are requested/needed (ASP.net needs to dynamically compile). Additionally, you are also exposing your source code on the server. It may not mean much depending on your situation, but it is one more thing to consider.

这里有更多关于预编译和选项的信息.

这篇关于ASP.NET 网站发布与复制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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