1. 一个关于asp.net的问题
你没有装.net框架消信或安装顺序不对,应该先装框架然后装iis,一般重装差咐过iis容易出现此情况.可以在.net的命令行下用aspnet_regiis -i命令修复拿庆轮
2. 用aspnet
在 模型中 vs 已经完全脱离了编译而成为了一个彻底的ide 算是一个不小的改动 其中更是取消了有关Web Application的概念 使得习惯了vs 的人刚开始的时候会有一些摸不著头脑 下面简单说一下我在使用过程中自己总结的 算是一点经验
新建web工程并且位置是文件系统的时候 vs 只是帮你建好了一个sln文件 这个东西只是指引m *** uild 如何进行编译的 过程是 ide 调用 m *** uild m *** uild解析sln文件 m *** uild调用aspnet_piler exe进行网站的编译 所以aspnet_piler exe只是负责进行网站的编译的
预编译的概念在framework 里面就存在了 vs 中的预编译指的是将页面对应的cs/vb文件与resx文件编译后统一集成到一个dll中放到bin目录下 将aspx文件直接拷贝过去 这样做会留下隐患 因为aspx文件就直接暴露在最后的发行包中 如果完全是codeb behind模型还好 只能改改界面 如果采用了页面上的来生成页面 源代码就暴露了 针对这些问题 vs 采用了一种新的模式
请参看ASP NET 编译工具 (Aspnet_piler exe) 这篇文章了解对各种文件的处理方式
IDE发布
vs 中选择 生成 〉发布网站 在对话框中的操作将映射到aspnet_piler exe的参数中 可更新的发布对应 u 其他选项类似 请参考上面的文章了解
注意 发布时将忽略nfig中的debug?问骋簧晌薜魇孕畔⒌奈募?
手工编译
简单说来 如果是无更新发布模式编译 appcode下面的class编译成dll放在bin下 页面内容清空位置不变作占位用 同时页面被编译成一个随机名称的dll 增加一个同piled文件到bin目录下 内容大概如下
<?xml version= encoding= utf ?>
<preserve resultType= virtualPath= /Forum/AdminList aspx hash= c filehash= f d c flags= assembly= App_Web_hmrycg w type= ASP forum_adminlist_aspx >
<filedeps>
<filedep name= /Controls/footer ascx />
<filedep name= /Controls/header ascx />
<filedep name= /Forum/AdminList aspx />
<filedep name= /Forum/AdminList aspx cs />
<filedep name= /Forum/menu ascx />
<filedep name= /Forum/menu ascx cs />
</filedeps>
</preserve>
里面只是列出了页面上的customcontrol 这里已经完成了和masterfile的映射 这样最大限度的保护了页面的敏感信息 发布过的网站中只能看见一堆文件名了 可更新的发布模式与vs 类似 页面就直接拷贝过来不予编译了
讲了一堆原理 下面说一下aspnet_piler exe的调用方法 这是我使用的例子
我的开发目录是这样的
Project/
library/
devroot/
pubroot/
proj sln
使用的命令如下
aspnet_piler v / p devroot f pubroot
分析
v / 指明了iis的虚拟目录
p devroot 表示代码实际位置
pubroot 指明了要发布的位置
f 表示强制改写目标位置
lishixin/Article/program/net/201311/13677
3. 如何解决写入XML文件时路径访问被拒绝
原因及解决方案:
此为文件写入权限问题,可如下操作解决(XP系统IIS5下尝试可行)
1、资源管理器->工具->文件夹选项->查看 不选"使用简单文件共享"
2、右击该xml文件(或者该文件所在文件夹),选"属性"点"安全"添加"aspnet",选中“写入”赋予写入权限,或者选"完全控制",然后确定即可。
以下为网络获取在windows2003服务器IIS6下出现该错误提示的参考解决方案,在此摘录仅供备份参考:
解决方案一
在需要进行读写操作的目录下添加Network Service这个帐号,
由于在iis 6.0中,默认的应用程序池中的标示用的是Network Service,
所以在进程中是使用Network Service这个帐号运行来运行w3wp.exe进程,
而当我们在运行VS 2003的时候需要对某一个目录下进行读写操作,
看了一下该文件夹,发现没有Network Service,添加上该账号,同时选上FULL CONTROL,问题解决,
解决方案二
在IIS6.0中的默认应用程序池-->属性-->标示中把Net Service改成Local System该问题也可以解决
4. ASP.NET 操作word文档(读写),怎么实现
展示word文件这个网上不少例子。但是写入word制定位置就是操作word文档了。1.这个隐约记得是把word文档分成好几个区域实现操作,但这个不知道具体思路。
2,。如果客户允许,可是加个连接或按钮,“编辑文档”。转到文本编辑器里面。
http://www.haoxiai.net/wangzhanzuo/aspnet/53267.html
这里面多少有点原理。楼主看看
5. aspnet2005如何对word文档进行操作
你安装完vs2005 tool for office后,在新建项目就有word模板了。。
你就可以对word进行操作了。
补充:
首先引入类库,Microsoft.Office.Interop.Word,然后进行编程。代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office.Interop.Word;
namespace WordTest
{
public partial class Form1 : Form
{
object strFileName;
Object Nothing;
Microsoft.Office.Interop.Word.Application myWordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
Document myWordDoc;
string strContent = "";
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
createWord();
//openWord();
}
private void createWord()
{
strFileName = System.Windows.Forms.Application.StartupPath + "test.doc";
if (System.IO.File.Exists((string)strFileName))
System.IO.File.Delete((string)strFileName);
Object Nothing = System.Reflection.Missing.Value;
myWordDoc = myWordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
#region 将数据库中读取得数据写入到word文件中
strContent = "你好\n\n\r";
myWordDoc.Paragraphs.Last.Range.Text = strContent;
strContent = "这是测试程序";
myWordDoc.Paragraphs.Last.Range.Text = strContent;
#endregion
//将WordDoc文档对象的内容保存为DOC文档
myWordDoc.SaveAs(ref strFileName, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
//关闭WordDoc文档对象
myWordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
//关闭WordApp组件对象
myWordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
this.richTextBox1.Text = strFileName + "\r\n" + "创建成功";
}
private void openWord()
{
fontDialog1.ShowDialog();
System.Drawing.Font font = fontDialog1.Font;
object filepath = "D:\\asp.docx";
object oMissing = System.Reflection.Missing.Value;
myWordDoc = myWordApp.Documents.Open(ref filepath, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
myWordDoc.Content.Font.Size = font.Size;
myWordDoc.Content.Font.Name = font.Name;
myWordDoc.Save();
richTextBox1.Text = myWordDoc.Content.Text;
myWordDoc.Close(ref oMissing, ref oMissing, ref oMissing);
myWordApp.Quit(ref oMissing, ref oMissing, ref oMissing);
}
}
6. ASP.NET创建文件并写入内容
在ASP NET中 文件处理的整个过程都是围绕着System IO 这个名称空间展开的 这个名称空间中具有执行文件读 写所需要的类 本文从最基本的操作开始 解释在ASP NET中文件处理的概念 包括如从一个文件中读取内容 如何向一个文件中写入内容和如何删除一个文件 前面已经提到 要想在ASP NET 页面中进行文件处理 必须要有 System IO 名称空间 所以 第一步就是引入这个名称空间 <%@ Import Namespace= System IO %>下一步 就是创建一个文本文件 并将这个文本文件分配给一个流书写对象 这样就可以向文本文件中写入内容了 用以下一段代码来完成这个任务 writefile aspx<%@ Import Namespace= System IO %><%Response write( Writing the content into Text File in ASP NET<BR> ) 声明流书写对象Dim strwriterobj As StreamWriter 创建文本文件 分配textfile对象strwriterobj= File CreateText( c:aspnet txt ) 写入内容strwriterobj WriteLine( Wele to wonderfull world of ASP NET Programming ) 完成樱悔操作 关闭流对象strwriterobj CloseResponse write( Done with the creation of text file and writing content into it )%>这样就完成了!现在让我们继续进行下一个任务 从刚才创建的文本文件中读取内容 从文件中读取内容从文件中读取内容与向文件中写入内容大致相同 只是要注意一下下面的两件事 文件读取使用StreamReader类 当使用了Readline方法时 将要被读取的文本文件的结尾处会用一个空字符串( )来标记 现在开始编写代码从前面创建的aspnet txt 文件中读取内容 readfile aspx<%@ Import Namespace= System IO %><%Response write( Reading the content from the text file ASPNET TXT<br> ) 创建流读取对象Dim streamreaderobj As StreamReader 声明变量 以存放从文件中读取的内容Dim filecont As String 打开文本文件 分配给流读乱判取对象streamreaderobj = File OpenText( c:aspnet txt ) 逐行读取文件内容Dofilecont = streamreaderobj ReadLine()Response Write( filecont & <br> )Loop Until filecont = 完成读取操作后 关闭流读取对象streamreaderobj CloseResponse write( <br>Done with reading the content from the file aspnet txt )%>删除文件在ASP NET中删除文件也非常简单和直观 System IO名称空间中的 File (文件)类有一个Delete方法用来删除文件 它把文件名作为一个自变量来传递 以下代码就演示了在ASP NET中进行文件哗颂改删除的步骤 Filedelete aspx<%@ Import Namespace= System IO %><%File Delete( c:aspnet txt )Response write( The File aspnet is deleted successfully !!! )%> lishixin/Article/program/ASP/201311/21860
7. asp.net文件写入权限问题
你的路径写错了
你用SERVER.PATH("AAAAA.TXT");试试行不行
8. ASP.NET安装部署之导入项目图解
将VbNetTest项目的输出添加到部署项目中(假如你的虚拟做吵目录是SQLANDASPNet)
在 文件系统编辑器 中 选灶早择纯辩侍 Web 应用程序文件夹 在 操作 菜单上 指向 添加 然后选择 项目输出
9. asp.net注册页面数据写入数据库问题。我用的是ACCESS数据库
是不是SQL语句错了。 insert into 你的少个into 另外第3个参数RadioButtonList1.SelectedItem.Value是object类型的,需要先转换成string才能往数据库插入。
10. asp.net 读写配置文件Web.Config
给你一个例子,你瞧瞧:
<appSettings>
<add key="ConnectionString" value="server=192.168.19.250;database=hrms_test;uid=pmstest;pwd=pmstest" />
<add key="WebObjectPath" value="http://localhost/LMS/Files/" />
<add key="PhysicsObjectPath" value="E:/Files/"/>
<add key="SystemCode" value="12" />
<add key="OrganizationPath" value ="organization" />
</appSettings>
public static string ConnectionString
{
get { return System.Configuration.ConfigurationManager.AppSettings["ConnectionString"].ToString(); }
}
/// <summary>
/// 组织架构数据库路径
/// </summary>
public static string OrganizationPath
{
get { return System.Configuration.ConfigurationManager.AppSettings["OrganizationPath"].ToString(); }
}
/// <summary>
/// 系统编码
/// </summary>
public static string SystemCode
{
get { return System.Configuration.ConfigurationManager.AppSettings["SystemCode"].ToString(); }
}
/// <summary>
/// 物理上传路径
/// </summary>
public static string PhysicsObjectPath
{
get { return System.Configuration.ConfigurationManager.AppSettings["PhysicsObjectPath"].ToString(); }
}
/// <summary>
/// 虚拟上传路径
/// </summary>
public static string WebObjectPath
{
get { return System.Configuration.ConfigurationManager.AppSettings["WebObjectPath"].ToString(); }
}