How to apply URL shortner in ASP.Net

Last Reply on Aug 23, 2016 02:32 AM By dharmendr

Posted on Aug 22, 2016 04:42 AM

Hi,

Does anyone here has a guide or has a sample project on URL shortner.I am also looking for guidance on URL Rewritting.

 

Thanks in advance

Results 1 - 5 of 7 12
Posted on Aug 22, 2016 04:42 AM

Posted on Aug 22, 2016 04:48 AM
Vikash21 says:

Hi,

Does anyone here has a guide or has a sample project on URL shortner.I am also looking for guidance on URL Rewritting.

 

Thanks in advance

 Hi Vikash21, Add the below code in your web.config inside <system.webServer /> to hide the .aspx extension.

<rewrite>
      <rules>
        <rule name="extensionless" stopProcessing="true">
          <match url="(.*)\.aspx"/>
          <action type="Redirect" url="{R:1}" redirectType="Permanent"/>
        </rule>
        <rule name="removeextension" enabled="true">
          <match url=".*" negate="false"/>
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
            <add input="{URL}" pattern="(.*)\.(.*)" negate="true"/>
          </conditions>
          <action type="Rewrite" url="{R:0}.aspx"/>
        </rule>
      </rules>
    </rewrite> 

 


Posted on Aug 22, 2016 10:42 PM

Thank you very much sir. What do I need to edit in this? And, any links or guide u can refer for URL Shortner?


Posted on Aug 22, 2016 11:14 PM
Vikash21 says:

Thank you very much sir. What do I need to edit in this? And, any links or guide u can refer for URL Shortner?

 Hi Vikash21,

you can refer the below link which is helpful to convert long urls to short urls using google API.

Create Goog.le Short Urls in JavaScript using Google URL Shortener API Example

 

 


Posted on Aug 22, 2016 11:19 PM

Actually I want long urls to shorten using a domain example:

Here;'s exactly what I am trying for

aspsnippets.com is my site

and I enter a long URL:

http://www.aspsnippets.com/Articles/How-to-hide-remove-ASPX-extension-in-URL-in-ASPNet.aspx

So it should return aspsnippets.com/exwly which should direct to 

http://www.aspsnippets.com/Articles/How-to-hide-remove-ASPX-extension-in-URL-in-ASPNet.aspx when used anywhere