<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: M.Usman Rafiq</title>
    <description>The latest articles on DEV Community by M.Usman Rafiq (@usmancode).</description>
    <link>https://dev.to/usmancode</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F173493%2Fbfb66cec-e7bb-413f-95bd-66da076de020.png</url>
      <title>DEV Community: M.Usman Rafiq</title>
      <link>https://dev.to/usmancode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/usmancode"/>
    <language>en</language>
    <item>
      <title>Asp.Net Core app with Dynamic Modular Monolith Architecture</title>
      <dc:creator>M.Usman Rafiq</dc:creator>
      <pubDate>Sat, 24 May 2025 17:51:11 +0000</pubDate>
      <link>https://dev.to/usmancode/aspnet-core-app-with-dynamic-modular-monolith-architecture-2apb</link>
      <guid>https://dev.to/usmancode/aspnet-core-app-with-dynamic-modular-monolith-architecture-2apb</guid>
      <description>&lt;p&gt;Last weekend, I was thinking about managing my finances in terms of total expenses per month and some sort of reporting for analysis so that I can monitor and make some decisions. I started looking for online available apps which can do this for me. Before coming to the main discussion, let me tell you, as a software engineer, this happens with me every time, as soon as a software is needed, the very next thought that comes to my mind is, why not let's create one? If I were the creator, I know the problem, I can develop as per my needs, and have complete control.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fchyjwicq14co9bspwmti.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fchyjwicq14co9bspwmti.png" alt="Image description" width="800" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With over 13 years of industry experience, I have come to realize that as your career progresses, it's the discussions and communication around a problem that truly matter. These interactions become a powerful source of learning and critical thinking. While writing code is very important for implementing solutions, the real growth often comes from how we explore and understand problems together. I believe you’ll come to appreciate that over time as well. Now, let’s return to the main topic. Up to this point, I had decided to develop an ASP.NET Core web application using .NET 9. The next crucial decision was choosing an architecture that allows building features in isolation, as self-contained modules, without needing to redeploy the entire application every time. Take a moment to pause and reflect on the title of this post: Dynamic Modular Monolith."&lt;/p&gt;

&lt;p&gt;That was all for this introductory post about my Dynamic Modular Monolith Architecture-based ASP.NET Core app, this is a series of posts, i.e., &lt;a href="https://www.usmancode.com/blog/aspnet-core-app-with-dynamic-modular-monolith-architecture-part-1" rel="noopener noreferrer"&gt;ASP.NET Core app with Dynamic Modular Monolith Architecture&lt;/a&gt;, which I thought I should share with the wider audience as well.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>dotnetcore</category>
      <category>architecture</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Develop 0 to Live your own website almost free</title>
      <dc:creator>M.Usman Rafiq</dc:creator>
      <pubDate>Fri, 28 Jun 2024 18:35:35 +0000</pubDate>
      <link>https://dev.to/usmancode/how-its-too-easy-to-set-up-your-own-website-almost-free-gmo</link>
      <guid>https://dev.to/usmancode/how-its-too-easy-to-set-up-your-own-website-almost-free-gmo</guid>
      <description>&lt;p&gt;We are living in the &lt;strong&gt;Industry 4.0&lt;/strong&gt; revolution and hearing about IoT and AI every day. I was thinking, should that be difficult for anyone to set up their own website seamlessly at almost free? I am a tech guy by profession, working with teams building software. So I should know the answer to what I have said. Yes, I do now after spending some time in the software development industry. Let me share the recipe with you which is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Purchase a domain, which costs $15 per year on average&lt;/li&gt;
&lt;li&gt;Buy a hosting space (can ignore if web app doesn't need backend support), I am using &lt;a href="https://www.SmarterASP.NET/index?r=usmanrafiq1" rel="noopener noreferrer"&gt;SmarterAsp.net&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Setup a GitHub repository and actions (it's free)&lt;/li&gt;
&lt;li&gt;And that's it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I have explained and demonstrated how we can achieve this step-by-step process in the following playlist.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/jC_fTzfnIvM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Let me know, what you think and feel free to ask any questions, this post is just the tip of the iceberg, keep coding.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>github</category>
      <category>tutorial</category>
      <category>dotnetcore</category>
    </item>
    <item>
      <title>Introduction to .NET 7 Minimal APIs</title>
      <dc:creator>M.Usman Rafiq</dc:creator>
      <pubDate>Sun, 15 Oct 2023 16:03:30 +0000</pubDate>
      <link>https://dev.to/usmancode/introduction-to-net-7-minimal-apis-2866</link>
      <guid>https://dev.to/usmancode/introduction-to-net-7-minimal-apis-2866</guid>
      <description>&lt;p&gt;The release of .NET 6 brought about several exciting features and improvements, and one of the most exciting additions is the Minimal API. Minimal APIs make it easier than ever to create lightweight and efficient web applications in .NET. With its immense usefulness, I have started this .net 7 minimal API series and this is the first part of it.&lt;/p&gt;

&lt;p&gt;To get started with Minimal APIs, you'll need .NET 6 SDK and Visual Studio 2022 or your preferred code editor. Here's a step-by-step guide to creating a simple Minimal API:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Create a New .NET 7 Project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can create a new project using the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dotnet new web -n MyMinimalApi&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Or alternatively, open Visual Studio 2022, and select the Asp.Net Web API project from Microsoft from the templates list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fftuaq49jfmrrzvuf9uia.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fftuaq49jfmrrzvuf9uia.png" alt="Select Project Type" width="800" height="565"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And once selected, in the next step, keep the "Use controllers" checkbox unchecked.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvgjvu9cwk77rgh0cvg09.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvgjvu9cwk77rgh0cvg09.png" alt="Controllers Checkbox" width="800" height="529"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Define Endpoints&lt;/strong&gt;&lt;br&gt;
In your Program.cs file, you'll define your endpoints using C# 10's new top-level statements. For example, a simple "Hello, World!" endpoint might look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var builder = WebApplication.CreateBuilder(args); 
var app = builder.Build(); 
 app.MapGet("/", () =&amp;gt; "Hello, World!"); 
 app.Run();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Run Your Application&lt;/strong&gt;&lt;br&gt;
You can run your application with the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dotnet run&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Your Minimal API is now up and running! You can access it by navigating to &lt;a href="http://localhost:5000" rel="noopener noreferrer"&gt;http://localhost:5000&lt;/a&gt; in your web browser.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
.NET Minimal APIs offer a straightforward and efficient way to build web applications in .NET. Whether you're a beginner or an experienced developer, Minimal APIs can simplify your development process, improve performance, and reduce boilerplate code. They are a powerful addition to the .NET ecosystem, and you should consider using them for your next project.&lt;/p&gt;

&lt;p&gt;For further detail, check my detailed blog post : &lt;a href="https://www.usmanrafiq.com/2023/10/net-7-minimal-apis-series-introduction.html" rel="noopener noreferrer"&gt;.Net 7 Minimal APIs Series - Introduction &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stay tuned for more in-depth tutorials and examples to help you make the most of Minimal APIs in .NET 7!&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>programming</category>
      <category>minimalapi</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How To Bind Model Value FromBody by Custom Binder in Asp.net Core</title>
      <dc:creator>M.Usman Rafiq</dc:creator>
      <pubDate>Thu, 30 May 2019 07:37:57 +0000</pubDate>
      <link>https://dev.to/usmancode/how-to-bind-model-value-frombody-by-custom-binder-in-asp-net-core-32ik</link>
      <guid>https://dev.to/usmancode/how-to-bind-model-value-frombody-by-custom-binder-in-asp-net-core-32ik</guid>
      <description>&lt;p&gt;I encountered a scenario a few days back where I was required to use a custom model binder to transform my received values in a FromBody JSON request. When I implemented the Model Binder It was working fine with FromQuery Attribute but was not working with FromBody, same issue as: &lt;a href="https://github.com/aspnet/Mvc/issues/8110" rel="noopener noreferrer"&gt;https://github.com/aspnet/Mvc/issues/8110&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For in-depth learning, you can also follow my channel on YouTube &lt;a href="https://www.youtube.com/channel/UCIzpLqvz1diUOAFzL08zjqg?sub_confirmation=1" rel="noopener noreferrer"&gt;@usmancode&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So after spending some hours on this problem, I came to know that the FromBody attribute will be handled using **BodyModelBinder **class with Formatters and ReaderFactory.&lt;/p&gt;

&lt;p&gt;public class MyModelBinder : IModelBinder&lt;br&gt;
  {&lt;br&gt;
      private BodyModelBinder defaultBinder;&lt;br&gt;
      public MyModelBinder(IList formatters, IHttpRequestStreamReaderFactory readerFactory)&lt;br&gt;
      {&lt;br&gt;
          defaultBinder = new BodyModelBinder(formatters, readerFactory);&lt;br&gt;
      }&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  public async Task BindModelAsync(ModelBindingContext bindingContext)
  {
      // calling the default body binder
      await defaultBinder.BindModelAsync(bindingContext);
      if (bindingContext.Result.IsModelSet &amp;amp;&amp;amp; bindingContext.Result.Model is ResetPasswordModel)
      {
          var inputModel = (ResetPasswordModel)bindingContext.Result.Model;

          // all of your property updates with be listed here
          //
          //
          //

          bindingContext.Result = ModelBindingResult.Success(inputModel);
      }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
And for this model binder, we will required a model provider which will be like :&lt;/p&gt;

&lt;p&gt;public class MyModelBinderProvider : IModelBinderProvider&lt;br&gt;
   {&lt;br&gt;
       private readonly IList _formatters;&lt;br&gt;
       private readonly IHttpRequestStreamReaderFactory _readerFactory;&lt;br&gt;
       private BodyModelBinderProvider _defaultProvider;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   public MyModelBinderProvider(IList&amp;lt;IInputFormatter&amp;gt; formatters, IHttpRequestStreamReaderFactory readerFactory)
   {
       _formatters = formatters;
       _readerFactory = readerFactory;
       _defaultProvider = new BodyModelBinderProvider(formatters, readerFactory);
   }

   public IModelBinder GetBinder(ModelBinderProviderContext context)
   {
       IModelBinder modelBinder = _defaultProvider.GetBinder(context);

       // default provider returns null when there is error.So for not null setting our binder
       if (modelBinder != null)
       {
           modelBinder = new ProtectedModelBinder(_formatters, _readerFactory);
       }
       return modelBinder;
   }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
And we need to register this provide in our startup class inside ConfigureServices method like :&lt;/p&gt;

&lt;p&gt;services.AddMvc(config =&amp;gt;&lt;br&gt;
           {&lt;br&gt;
               var readerFactory = services.BuildServiceProvider().GetRequiredService();&lt;br&gt;
               config.ModelBinderProviders.Insert(0, new MyModelBinderProvider(config.InputFormatters, readerFactory));&lt;br&gt;&lt;br&gt;
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);&lt;br&gt;
And at last annotate the model you want to customize the binding of which with a line as below:&lt;/p&gt;

&lt;p&gt;[ModelBinder(BinderType = typeof(MyModelBinder))]&lt;br&gt;
public class ResetPasswordModel : UserConfirmationModel&lt;br&gt;
And now if you make a http post api call with content type application/json with your model properties in request body then your custom model binding will work.&lt;/p&gt;

&lt;p&gt;You can fork our github repository for all useful and examples code : &lt;a href="https://github.com/Usman-uzi/techintalk" rel="noopener noreferrer"&gt;https://github.com/Usman-uzi/techintalk&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For all my blog posts you can visit : https:&lt;a href="http://www.techintalk.com" rel="noopener noreferrer"&gt;www.techintalk.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aspdotnetcore</category>
      <category>csharp</category>
      <category>modelbinding</category>
    </item>
  </channel>
</rss>
