I think I figured it out:
I placed the code in an aspx page in the module folder and removed the <form> tags from it. The codebehind is shown here:
ViewImage.aspx.cs
{insert the necessary using statements here}
namespace MyCompany.Modules.MyModule
{
public partial class ViewImage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int imageId;
int moduleId;
if ((Request.QueryString["imageId"] == null) || (Request.QueryString["moduleId"] == null))
return;
if (!(int.TryParse(Request.QueryString["imageId"].ToString(), out imageId)))
return;
if (!(int.TryParse(Request.QueryString["moduleId"].ToString(), out moduleId)))
return;
writeImage(moduleId, imageId);
}
protected void writeImage(int _ModuleID, int _ItemID)
{
MyModuleController objMyModulePerson = new MyModuleController();
MyModuleInfo MyModulePerson = new MyModuleInfo();
MyModulePerson = objMyModulePerson.GetMyModule(_ModuleID, _ItemID);
if (MyModulePerson.CreatedByUser > 0)
{
if (MyModulePerson.Picture.Length != 0)
Response.BinaryWrite(MyModulePerson.Picture);
}
}
}
}
The code for the grid, which is pretty simple is in the module ascx file. I am not going to post it, because I used a third-party component, but if you are interested you can follow this link.
Hope this helps somebody.