Ehsan Ghanbari

Experience, DotNet, Solutions

The combination of Stackify and Netling are doing a great job!

There are lots of tools and libraries out there for monitoring the Dot Net web applications. I personally use several tools based on my need. One of the tools I've always liked is Netling. It's great for fetching some overall results about the load time and resource usages of the application on heavy requests.  Rather than that, I usually use another code monitoring tool to see what's going exactly in my code. Get the latest version of Stackify and Netling. Firstly, run the Netling client and test your application load via different Threads, I'm testing the app on my website source code:



You can see the result in the picture above for 16 threads. Note that I'm running the app on my local computer machine and running on the web server would appear different result:



Anyway, you can see about the details of each parameter of Netling over here. Netling gives us overall result about the load and performance but it doesn't give us which section or which method causes the load issue. As I told, Stackify is a great tool for code monitoring; After installing and enabling the application via the mentioned link at the beginning of the post, run your application and see the result in the local address that Stackify gives you:



It's obviously shown that which action takes more time than others. And by selecting the action on the left side you can see the details on the right side. You can detect the heavy queries and modify them. needless to say that, Stackify code monitoring and you can only use it in your local machine on your source code.

Using glimps in mvc

I've always loved and used Glimpse at least for my basic performance and load test in my MVC projects. It's really straightforward and easy to use web debugging and diagnostics tool. Get the latest version of the library from nuget and get started. After installing the suitable version based on your MVC version, go to the yourApplicationUrl/Glimpse.axd and enable it.



Then you will see the Glimpse layout at the bottom of every page of your application:



After redirecting to the different page, you can easily see the details of your request such as Execution, Metadata, Model Binding, Routes, and even SQL queries:



Glimpse just inform you about your application, You can use this tool in your application I recommend you to close it in final production:





Syntaxhighlighter plugin in CKEditor

 There are lots of plugins for CKEditor and one of the most used plugin for the developers is SyntaxHighlighter. In order to get and install this nice one with a sexy them like the following picture:

Get the latest version from the website and copy the content of the plugin into the plugin folder. Note that you should get the requirement plugin of every plugin in CKEditor of course, you will see the following popup modal after clicking the download button:

And the Dialog plugin needs Dialog User Interface as well. So after getting all three plugins and putting in the plugin folder. You just need to define the plugin like below:

<textarea id="js-my-textarea"></textarea>

<script type="text/javascript">

    CKEDITOR.replace('js-my-textarea', {

        "extraPlugins": 'syntaxhighlight'




If you run your application you will see the plugin, you just need to copy and paste your code and select the language. That's all!



But you don't have that sexy highlighter yet! You need to add some CSS and JS code wherever your final body would be rendered. You have to get those extra files from highlighter web site. Get the latest version, after extracting you will see Scripts and Styles folder:



Some files are needed to be referenced like XRegExp.js, shCore.js, shCore.css, shThemeDefault.css :


    <script src="~/Content/syntaxhighlighter/scripts/XRegExp.js"></script>
    <script src="~/Content/syntaxhighlighter/scripts/shCore.js"></script>

    <script src="~/Content/syntaxhighlighter/scripts/shBrushCSharp.js"></script>
    <script src="~/Content/syntaxhighlighter/scripts/shBrushCss.js"></script>
    <script src="~/Content/syntaxhighlighter/scripts/shBrushJava.js"></script>
    <script src="~/Content/syntaxhighlighter/scripts/shBrushJScript.js"></script>
    <script src="~/Content/syntaxhighlighter/scripts/shBrushPython.js"></script>
    <script src="~/Content/syntaxhighlighter/scripts/shBrushRuby.js"></script>
    <script src="~/Content/syntaxhighlighter/scripts/shBrushSql.js"></script>
    <script src="~/Content/syntaxhighlighter/scripts/shBrushXml.js"></script>

    <link href="~/Content/syntaxhighlighter/styles/shCore.css" rel="stylesheet" />
    <link href="~/Content/syntaxhighlighter/styles/shThemeDefault.css" rel="stylesheet" />
    <script type="text/javascript">SyntaxHighlighter.all();</script>

Then you can reference all the language you want to highlight. By the way, you can find some other template rather than the default (shThemeDefault.css) in the same folder. 

Image browse plugin in CKEditor

I was recently integrating my blog with CKEditor Image Browser plugin and it was interesting to me, It was cool! in order to add Image Browser plugin to your CKEditor you should get the file from the mentioned link and put it in your plugins folder inside CKEditor. Then you should go to the config.js file of CKEditor and add the target plugin:

CKEDITOR.editorConfig = function( config ) {

// Define changes to default configuration here. For example:

// config.language = 'fr';

// config.uiColor = '#AADC6E';

    config.extraPlugins = 'imagebrowser';

    config.extraPlugins = 'prism';

    config.extraPlugins = 'codesnippet';

    config.extraPlugins = 'widget';

    config.extraPlugins = 'dialog';


Now before browsing, if you run your application, you would see the image properties with  Browse server button:



Now you should tell the plugin that where your images should be getting, imageBrowser_listUrl is the URL which should return a JSON file:

 <textarea id="my-textarea-id"></textarea>

 <script type="text/javascript">

    CKEDITOR.replace('js-my-textarea', {

        "extraPlugins": 'imagebrowser',

        "imageBrowser_listUrl": "/Administrator/File/BrowseImages"



As I've written my blog with MVC4, I used HTML helper instead of <textarea> tag:

     @Html.TextAreaFor(blog => blog.Body, new { @id = "js-my-textarea", @class = "ckeditor" })

Image browser in CKEditor needs the JSON result in a format like this:



                "image": "/image1.jpg",

                "thumb": "/image1_thumb.jpg"



                "image": "/image2_.jpg",

                "thumb": "/image2_thumb.jpg"                



To create a JSON file like this in MVC, make JsonResult with the same output:

 public JsonResult BrowseImages()


            var imageBrowser = new List<ImageBrowserViewModel>();

            var path="/Images/"

            var images = Directory.GetFiles(Server.MapPath(path)).OrderByDescending(d => new FileInfo(d).CreationTime);

            foreach (var image in images)


                imageBrowser.Add(new ImageBrowserViewModel


                    image = string.Format(finalPath + Path.GetFileName(image)),

                    thumb = string.Format(finalPath + "Thumb/" + Path.GetFileName(image)),



            return Json(imageBrowser, JsonRequestBehavior.AllowGet);


And the ImageBrowserViewModel is just a ViewModel to initiate the output:

 public class ImageBrowserViewModel


        public string image { get; set; }


        public string thumb { get; set; }


As you can see in my code and also based on the required JSON output, I save the thumb of my images to show them in image browser to pick. Now you can see the output of your plugin in your editor:


JWT token in swagger

In Core, for authorized APIs you can easily pass the JWT token via PostMan like below: 

But swagger you don't have authentication by installing it, add the following configuration to services to enable the authentication in swagger  as well:

 services.AddSwaggerGen(options =>
                options.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
                options.AddSecurityDefinition("oauth2", new ApiKeyScheme
                    Description = "Standard Authorization header using the Bearer scheme. Example: \"bearer {token}\"",
                    In = "header",
                    Name = "Authorization",
                    Type = "apiKey"

You will see the Authorize button on top right corner:


About Me

Ehsan Ghanbari

Hi! my name is Ehsan. I'm a developer, passionate technologist, and fan of clean code. I'm interested in enterprise and large-scale applications architecture and design patterns and I'm spending a lot of my time on architecture subject. Since 2008, I've been as a developer for companies and organizations and I've been focusing on Microsoft ecosystem all the time. During the&nb Read More

Post Tags
Pending Blog Posts
Strategic design
Factory Pattern
time out pattern in ajax
Selectors in Jquery
Peridic pattern
How to use PagedList In MVC
How to query over Icollection<> of a type with linq
Domain driven design VS model driven architecture
Redis as a cache server
What's the DDD-lite?