<?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: Hassan Farooqui</title>
    <description>The latest articles on DEV Community by Hassan Farooqui (@hassanfarooqui).</description>
    <link>https://dev.to/hassanfarooqui</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%2F1147655%2F7250b77c-ae45-4da6-9714-b3fb74562076.jpeg</url>
      <title>DEV Community: Hassan Farooqui</title>
      <link>https://dev.to/hassanfarooqui</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hassanfarooqui"/>
    <language>en</language>
    <item>
      <title>Routing in .Net Core</title>
      <dc:creator>Hassan Farooqui</dc:creator>
      <pubDate>Wed, 07 May 2025 14:19:21 +0000</pubDate>
      <link>https://dev.to/hassanfarooqui/routing-in-net-core-5chm</link>
      <guid>https://dev.to/hassanfarooqui/routing-in-net-core-5chm</guid>
      <description>&lt;p&gt;Routing is a mechanism that maps incoming requests to its corresponding end point. &lt;/p&gt;

&lt;p&gt;There are two types of routing in dotnet core:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Convention based routing:&lt;/strong&gt;&lt;br&gt;
It is defined in startup or program.cs files and normally used in MVC applications. &lt;/p&gt;

&lt;p&gt;Example: &lt;br&gt;
app.UseEndpoints(endpoints =&amp;gt;&lt;br&gt;
{&lt;br&gt;
    endpoints.MapControllerRoute(&lt;br&gt;
        name: "default",&lt;br&gt;
        pattern: "{controller=Home}/{action=Index}/{id?}");&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attribute Routing:&lt;/strong&gt;&lt;br&gt;
Apply on controllers using decorators such as [Route], [HttpGet] etc. It is more flexible than convention based routing. It is used in Restful services. &lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
[Route("api/products")]&lt;br&gt;
public class ProductsController : Controller&lt;br&gt;
{&lt;br&gt;
    [HttpGet("{id}")]&lt;br&gt;
    public IActionResult GetProduct(int id) { ... }&lt;br&gt;
}&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>api</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Web API Conventions</title>
      <dc:creator>Hassan Farooqui</dc:creator>
      <pubDate>Wed, 07 May 2025 14:15:49 +0000</pubDate>
      <link>https://dev.to/hassanfarooqui/web-api-conventions-235k</link>
      <guid>https://dev.to/hassanfarooqui/web-api-conventions-235k</guid>
      <description>&lt;p&gt;Web API Convention:&lt;/p&gt;

&lt;p&gt;Web API conventions are basically set of rules that guides to build maintainable, scalable APIs and and provides consistency as well. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use of Http methods properly like GET, PUT, POST, PATCH, DELETE.&lt;/li&gt;
&lt;li&gt;Then it comes to naming convention which tells us to use nouns not verbs such as /users , /invoices etc. &lt;/li&gt;
&lt;li&gt;One more thing in namming convention is that not to use action in the path for example /getUsers instead of it use method GET and keep name a noun like /users.&lt;/li&gt;
&lt;li&gt;The third thing using appropriate status codes for corresponding status for example 200 for success and 400 for bad request and so on.&lt;/li&gt;
&lt;li&gt;And at last use versioning e.g. /v1/users and consistent request and response formats i.e. JSON format. &lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>api</category>
      <category>restapi</category>
      <category>conventions</category>
      <category>http</category>
    </item>
    <item>
      <title>Creating Customized Offline Captcha in Angular 🔥✌</title>
      <dc:creator>Hassan Farooqui</dc:creator>
      <pubDate>Tue, 29 Aug 2023 18:45:38 +0000</pubDate>
      <link>https://dev.to/hassanfarooqui/creating-customized-offline-captcha-in-angular-i5m</link>
      <guid>https://dev.to/hassanfarooqui/creating-customized-offline-captcha-in-angular-i5m</guid>
      <description>&lt;h2&gt;
  
  
  Hola Folks!!
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;We are going to develop our offline captcha with typescript in just 5 minutes.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Only 5 steps we are going to follow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;create function for random string&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;initialize a variable array to store random string&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generate captcha of your desired length i.e. 4 or 5 and so on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;call that random string with a background image in template file&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;validate and refresh captcha&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Let's start
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; makeRandom(lengthOfCode: number, possible: string)
{
    let text = "";
    for(let i = 0; i&amp;lt; lengthOfCode; i++)
    {
      text += possible.charAt(Math.floor(Math.random() * possible.length));
  }
    return text;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;above is the function for generating random string. now lets go further. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Initializing variables as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  captchaText: any =[]
  captchaEntered: String = ""

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now so variable has been initialized, lets call makeRandom function to generate desired captcha.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;generateCaptcha()
{
  let possible= "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
  const lengthOfCode = 1

  for (let i=0; i&amp;lt; 5; i++)
  {
    let captchaChar = this.makeRandom (lengthOfCode, possible)
    this.captchaText[i] = captchaChar
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;generateCaptcha function can be used on refresh button as well to regenerate captcha.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;step 4&lt;/strong&gt;&lt;br&gt;
So now captcha has been generated, we are now calling it on our browser page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div style="background-image: url('./assets/captcha.jpg');"&amp;gt;
  &amp;lt;div *ngFor="let captcha of captchaText"&amp;gt;
    &amp;lt;b&amp;gt;{{captcha}}&amp;lt;/b&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;div&amp;gt;
  &amp;lt;input type="text" [(ngModel)]="this.captchaEntered" maxlength="5"&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you can use any image suitable to you as a captcha background.&lt;br&gt;
secondly you can validate or refresh captcha on your desired submit button.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;step 5&lt;/strong&gt;&lt;br&gt;
So the last one we are validating the captcha end user entered:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
validateCaptcha ()
{
  let i=0
  this.captchaEntered = this.captchaEntered.toLocaleUpperCase()
  for (i; i&amp;lt;5; i++)
  {
    if (this.captchaEntered.charAt(i) != this.captchaText[i])
    {
      alert('wrong captcha entered')
      return
    }
  }

  //captcha verified your further code here

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;_here you go enjoy!!!!! _&lt;/p&gt;

</description>
      <category>captcha</category>
      <category>angular</category>
      <category>tutorial</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
