Click here to Skip to main content
14,367,300 members

Verifying MSMQ is working fine for IIS based web applications

Rate this:
0.00 (No votes)
Please Sign up or sign in to vote.
0.00 (No votes)
22 Apr 2019CPOL
Access rights issue over MSMQ could lead to hours and hours of investigation


Recently we have a faced a production issue where our web application is not able to write in our queue. Since all writing over queue is encapsulated in COM based Wrapper class which only returns Boolean in case of success or failure, which leads us hours and hours on investigation and leads to nowhere. But the same wrapper class works outside of IIS (Desktop version of the application)

In order to improve investigation we have quickly built a sample web application which inserts a message into defined queue.

Image 1

Above screen create appropriate messages in the message queue (See below)

Image 2

Using the code

The code is extreamly simple to use and by nature self explainatory. 

protected void btnSubmit_OnClick(object sender, EventArgs e)
    StringBuilder sb = new StringBuilder();
        sb.Append("btnSubmit_OnClick Called" + "<BR/>");
        System.Messaging.Message msg = new System.Messaging.Message();

        sb.AppendLine("Msg.Label => " + txtLabel.Value + "<BR/>");

        msg.Label = txtLabel.Value;

        sb.AppendLine("Msg.Body => " + txtareaBody.Value + "<BR/>");

        msg.Body = txtareaBody.Value;

        sb.AppendLine("Initiating Message Queue => " + txtQueueName.Value + "<BR/>");
        MessageQueue mq = new MessageQueue(txtQueueName.Value);

        sb.AppendLine("Message Queue Exisits?" + "<BR/>");
        if (MessageQueue.Exists(mq.Path) == false)
            sb.AppendLine("Message Queue not exist, aborting operation" + "<BR/>");
            sb.AppendLine("Message Queue exist" + "<BR/>");
            sb.AppendLine("Initiating send message" + "<BR/>");
            sb.AppendLine("Send Message Success" + "<BR/>");
    catch (Exception ex)
        sb.Append(ex.ToString() + "<BR/>");

    outputMessage = sb.ToString();


This sample application help us identifying access issues and leads to resolution

Points of Interest

This sample application help us identifying access issues and leads to resolution


1.0  First Version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Architect Avanza Solutions
Pakistan Pakistan
Asif has started programming back in 1991 on 80286 8-16 MHZ systems. Started from dBase III+, FoxPro, C, assembly (exceptional skills in Assembly language have added a significant confidence in his development career). The programming saga continues exploring new technologies and languages ranging from C++, VC++, Java, Delphi, RPG400, SQL Server, Oracle to name a few and the exploration still continues to DOT Net Technologies, SOA architectures, BI, DSL, etc. These learning experiences are backed by strong theoretical background with a flavor of research.

Asif show significant interest in reading fiction, bio technology, Astronomy. He Loves watching movies and in free time love to play with his kids.

Comments and Discussions

-- There are no messages in this forum --
Posted 22 Apr 2019


2 bookmarked