-1

I am following the link to save text to image from the following link: How to generate an image from text on fly at runtime . Taken the code from the accepted answer . It is working fine in local machine.

The same program is promoted to a build server in a remote machine. And the url I am accessing from my local machine to save the text to image. The output says "Image is saved", but actually the image is not saved in the path saved in web.config of remote server. I am not even getting any error message to know whats the problem as there is no exception.

I am running out of ideas as in what could be the issue and why the image is not getting saved. Any suggestions?

Community
  • 1
  • 1
user1400915
  • 1,933
  • 6
  • 29
  • 55
  • 1
    whether it works locally or not, it would still help is you add the relevant code to your question. – Wim Ombelets Oct 29 '15 at 09:17
  • 1
    I have provided the link in the question : http://stackoverflow.com/questions/2070365/how-to-generate-an-image-from-text-on-fly-at-runtime . I am using the accepted answer as the code which works fine – user1400915 Oct 29 '15 at 09:18
  • Maybe there is a problem with the path? Could you please show us the path you are using in `img.Save(?¿)` – frikinside Oct 29 '15 at 09:22
  • 2
    It could be the folder you are trying to save in production server is "read-only" and not allowed to "write". This usually can be changed in hosting panel. – Emre Oct 29 '15 at 09:22
  • @frikinside :the path in web.config Is D:\img .... – user1400915 Oct 29 '15 at 09:32
  • @Emre : If I dont have a permission , then I am catching the exception and wrting to db table. That is also not happening . Thats why I am running out of ideas – user1400915 Oct 29 '15 at 09:32
  • 2
    Make sure the folder foresees modify rights to the IIS Apppool identity of the application. You'll need to add it by searching for it in full instead of just the identity, so `IIS APPPOOL\YourAppsIdentity`. Also set `` in the web.config's `` section during development so you get some more info if or when exceptions do bubble up. You can make this code a little more robust by doing some access control checks on the directory before attempting a write operation. [this](http://stackoverflow.com/a/3769421/1226915) can help you on your way. – Wim Ombelets Oct 29 '15 at 09:39
  • Hosting provider allows file to save in space/folder assigned to you. Check your control panel or ask hosting provider to get the path of where your asp.net files resides. Once done use that path to create file. – Amit Bhagat Oct 29 '15 at 12:46
  • @WimOmbelets : Please provide the comments in the answer section so that I can mark it as the accepted answer – user1400915 Oct 30 '15 at 06:05

1 Answers1

2

Here are some things you can do:

  • Make sure the folder where you are writing to foresees modify rights to the IIS Apppool identity of the application. You'll need to add it by searching for it in full instead of just the identity, so

IIS APPPOOL\YourAppsIdentity

(note the space between IIS and APPPOOL) and be sure to set the search location to the server machine, not to the domain, which is what it would default to if the machine is joined into one (otherwise the name won't resolve).

  • In your application's Web.config file you could also set <customErrors mode="Off"> (in the <system.web> section) during development so you get some more verbose error descriptions in the browser window if or when exceptions do bubble up. They can help you on your way to figure out what's going wrong. Don't forget to remove the entry from the Web.config file again once the application goes into production or set the value to "On" if you do, in fact, use custom errors.
  • You can make this code a little more robust by doing some access control checks on the directory before attempting a write operation. this can help you on your way.

Hope this helps.

Community
  • 1
  • 1
Wim Ombelets
  • 5,097
  • 3
  • 39
  • 55