Create a new webpage using a WCF service
I'd like to create WCF operation contract which consumes a string, produces a public webpage and then returns the address of this new page.
[ServiceContract(Namespace = "")]
public class DatabaseService
{
[OperationContract]
public string BuildPage(string fileName, string html)
{
//writes html to file
//returns public file url
}
}
This doesn't seem like it should be complicated but i cant figure out how to do it. So far what i've tried is this:
[OperationContract]
public string PrintToFile(string name, string text)
{
FileInfo f = new FileInfo(name);
StreamWriter w = f.AppendText();
w.Write(text);
w.Close();
return f.Directory.ToString();
}
Here's the problem. This does not create a file in the web root, it creates it in the directory w开发者_如何学JAVAhere the webdav server is running. When i run this on an IIS server it seems to do nothing at all (at least not that i can tell). How can I get a handle to the webroot programmatically so that i can place the resultant file there and then return the public URL? I can tack on the domain name after the fact without issue so if it only returns the relative path to the file that's fine.
Thanks, brian
Why do you need to programatically determine the path, don't you know the it? Can't you just put it in a config file and read it from there?
精彩评论