views:

27

answers:

2

Hi, i'm trying to write a text file on remote server, i'm using the following code:

[AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Index(UserModels model)
    {
        if (!ModelState.IsValid)
        {
            return View("Index");
        }

        try
        {
            using (StreamWriter w = new StreamWriter(Server.MapPath(TEXT_FILE_NAME), true))
            {
                w.WriteLine(model.Email.ToString()); // Write the text
            }
        }
        catch
        {
        }

the folder is still empty, can someone help? what should be the problem? Thanks

A: 

Any errors will be caught by the try and then as your catch block is empty be ignored. Try commenting out the try/catch and see if any exceptions are thrown that give you a clue as to what is going wrong.

Richard
A: 

Thank you all, the answer is just enable write/read permission on the server, there is nothing to do with mvc, the code is working properly.

Liado