0

i have a vs solution with 3 projects

MyCore: class library with DAL,BLL,helper functions etc...

MyWebsite: asp.net website which references MyCore

MyApplication: wpf app that also references MyCore

this setup allows me to reuse all the same functionality in the website and in the app.

the only problem is images. right now all icons i keeps separately in the website (and are accessed by their url) and also in the desktop app (accessed as resource)

is there any way i can somehow store the icons in MyCore and use them in both projects?

any ideas?

thank you all very much for your time and patience

1 Answer 1

1

An easy and strait forward way is to put all your images in a seperated Class (or in your case in MyCore) as a Ressource (Turn access modifier to public!).

At this point you can use an HTTPHandler as ImageHandler, which streams the images of your ressource file as "normal" images to your webpage, e.g.

public class ImageHandler : IHttpHandler
{
  public void ProcessRequest(HttpContext context)
  {
    context.Response.ContentType = "image/jpg";
    context.Response.Clear();

    Bitmap image = ClassLibrary1.Resource1._1346135638012;
    image.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);

  }

  public bool IsReusable
  {
    get
    {
        return false;
    }
   }
 }

You could use a get parameter to identify which images has to be streamed, e.g.

<image src="./ImageHandler.ashx?ImageId=123" />

And - of course - you could use the ressoures for your application as well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.