Click here to Skip to main content
15,920,956 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i try to build a page.aspx by this code:
C#
File.WriteAllText(Server.MapPath(FileName + ".aspx"),"aspnetcode");


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


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


but the error is:

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

what's the problem?
thnx
Posted

1 solution

Take the Server.MapPath part out, and you have a virtual path - as it expects...
C#
Server.Execute("~/" + FileName+".aspx");
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]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900