GithubHelp home page GithubHelp logo

fxmauricard / aspnetcore-url-shortener Goto Github PK

View Code? Open in Web Editor NEW
51.0 4.0 19.0 687 KB

A basic implementation of an URL shortener web site using ASP.NET Core.

License: GNU General Public License v3.0

C# 50.48% CSS 1.00% JavaScript 0.15% HTML 48.37%
csharp dotnet-core asp-net-core asp-net-core-mvc url-shortener asp mvc

aspnetcore-url-shortener's Introduction

ASP.NET Core MVC URL Shortener

A basic implementation of an URL shortener web application using ASP.NET Core MVC and Entity Framework Core.

Goal

I've started this little project in order to have a support during my approach of ASP.NET Core MVC.

My idea was to implement a simple web application using the framework.

I've chosen to implement an URL shortener application because it's pretty simple.

Algorithm

So, how works an URL shortener?

Basically, we store the URL in database, so it has a numeric ID, and we convert it to a another base in order to have a "stringified" version of the ID.

When we have the short URL, the process is:

  • convert the "stringified" ID to the numeric ID.
  • load the data from DB.
  • redirect to the original URL using an HTTP redirection.

More theory here in this stackoverflow topic.

Implementation

For the stringification, I've chosen base 62 with this alphabet: "23456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ-_".

I've used the ShortURL class by delight.im to do this work. See this link for more information about it.

You can also see this link: https://gist.github.com/dgritsko/9554733.

Usage

First, you have to type dotnet restore in order to retrieve the dependencies of the project.

The project is using SQLite as DB backend. The data file is named shorturls.db by default. You can change this by modifying the line 45 of the file Startup.cs.

In order to init the DB schema, you have to run the command dotnet ef database update.

Then, simply type dotnet run on your command prompt and then browse to http://localhost:5000.

Screenshot of the web application:

Screenshot of the ASP.NET Core MVC URL Shortener web application

Conclusion

ASP.NET Core allowed me to do this simple app in the quickest way. So that, I've doing more investigations about the framework.

aspnetcore-url-shortener's People

Contributors

andy840119 avatar dependabot[bot] avatar fxmauricard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.