server.execute的问题 [英] problem with server.execute

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

问题描述

我尝试通过以下代码构建page.aspx:

i try to build a page.aspx by this code:

File.WriteAllText(Server.MapPath(FileName + ".aspx"),"aspnetcode");





然后我想通过server.execute()运行创建的页面:







then i want to run the created page by server.execute():


Server.Execute(Server.MapPath("~/"; + FileName+".aspx"));





但错误是:



子请求'C:..... \ok.aspx''的路径无效。预计会有一条虚拟路径。



这是什么问题?

thnx



but the error is:

Invalid path for child request ''C:.....\ok.aspx''. A virtual path is expected.

what''s the problem?
thnx

推荐答案

取出Server.MapPath部分,你有一个虚拟路径 - 正如它所期望的那样......

Take the Server.MapPath part out, and you have a virtual path - as it expects...
Server.Execute("~/" + FileName+".aspx");

但是我会为它们设置一个文件夹 - 或者你的网站根文件夹会填满你不知道的文件,如果可以的话删除...



刚注意到你不想要分号...... - OriginalGriff [/ edit]

But I would set up a folder for them - or your website root folder will fill up with files you don''t know if you can delete...

[edit]Just noticed you don''t want the semicolon either... - OriginalGriff[/edit]


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

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