Search code examples
c#visual-studio-2010publish

Prevent delete user generated content on visual studio 2010 publish


I have an application that stores images uploaded by user. Those images goes to content/images/upload. Problem is that if i published without the skip extra files on destination, all user uploaded content gets deleted. Im pretty sure im doing it wrongly, which would be the best approach for this situation ?

im worried about losing user generated content this way misconfiguring an option in publish.


Solution

  • One approach I've used is to move the physical path of the "upload" older outside the application folder structure. I'd use an IIS virtual directory to mount the folder to the application. For example, if the folder structure currently looks like this:

    c:\inetpub\
        wwwroot\
            content\
                images\
                    upload\
    

    You might change it to this:

    c:\inetpub
        upload\   <-- must be manually created on the web server
        wwwroot\
            content\
                images\
    

    You'd remove the upload folder from the web application in Visual Studio. Log into the webserver and create the folder under inetpub (could go anywhere, really). Then go into IIS manager and create a virtual directory called upload that points to the c:\inetpub\upload folder.

    The upload folder is no longer part of the Visual Studio project so the "publish" feature won't touch it.