Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1a2e79e

Browse files
Md. Almajid KOUSHiKMd. Almajid KOUSHiK
Md. Almajid KOUSHiK
authored and
Md. Almajid KOUSHiK
committed
Ini Commit.....
1 parent b561097 commit 1a2e79e

File tree

413 files changed

+387638
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

413 files changed

+387638
-0
lines changed
61 KB
Binary file not shown.

‎WebAPIExample/.vs/config/applicationhost.config

Lines changed: 1038 additions & 0 deletions
Large diffs are not rendered by default.

‎WebAPIExample/WebAPIExample.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPIExample", "WebAPIExample\WebAPIExample.csproj", "{B79457F1-1885-4686-82B8-D45E3243B209}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{B79457F1-1885-4686-82B8-D45E3243B209}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{B79457F1-1885-4686-82B8-D45E3243B209}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{B79457F1-1885-4686-82B8-D45E3243B209}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{B79457F1-1885-4686-82B8-D45E3243B209}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Web;
2+
using System.Web.Optimization;
3+
4+
namespace WebAPIExample
5+
{
6+
public class BundleConfig
7+
{
8+
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
9+
public static void RegisterBundles(BundleCollection bundles)
10+
{
11+
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
12+
"~/Scripts/jquery-{version}.js"));
13+
14+
// Use the development version of Modernizr to develop with and learn from. Then, when you're
15+
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
16+
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
17+
"~/Scripts/modernizr-*"));
18+
19+
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
20+
"~/Scripts/bootstrap.js",
21+
"~/Scripts/respond.js"));
22+
23+
bundles.Add(new StyleBundle("~/Content/css").Include(
24+
"~/Content/bootstrap.css",
25+
"~/Content/site.css"));
26+
}
27+
}
28+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Web;
2+
using System.Web.Mvc;
3+
4+
namespace WebAPIExample
5+
{
6+
public class FilterConfig
7+
{
8+
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
9+
{
10+
filters.Add(new HandleErrorAttribute());
11+
}
12+
}
13+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System.Threading.Tasks;
2+
using Microsoft.AspNet.Identity;
3+
using Microsoft.AspNet.Identity.EntityFramework;
4+
using Microsoft.AspNet.Identity.Owin;
5+
using Microsoft.Owin;
6+
using WebAPIExample.Models;
7+
8+
namespace WebAPIExample
9+
{
10+
// Configure the application user manager used in this application. UserManager is defined in ASP.NET Identity and is used by the application.
11+
12+
public class ApplicationUserManager : UserManager<ApplicationUser>
13+
{
14+
public ApplicationUserManager(IUserStore<ApplicationUser> store)
15+
: base(store)
16+
{
17+
}
18+
19+
public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
20+
{
21+
var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));
22+
// Configure validation logic for usernames
23+
manager.UserValidator = new UserValidator<ApplicationUser>(manager)
24+
{
25+
AllowOnlyAlphanumericUserNames = false,
26+
RequireUniqueEmail = true
27+
};
28+
// Configure validation logic for passwords
29+
manager.PasswordValidator = new PasswordValidator
30+
{
31+
RequiredLength = 6,
32+
RequireNonLetterOrDigit = true,
33+
RequireDigit = true,
34+
RequireLowercase = true,
35+
RequireUppercase = true,
36+
};
37+
var dataProtectionProvider = options.DataProtectionProvider;
38+
if (dataProtectionProvider != null)
39+
{
40+
manager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity"));
41+
}
42+
return manager;
43+
}
44+
}
45+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Mvc;
6+
using System.Web.Routing;
7+
8+
namespace WebAPIExample
9+
{
10+
public class RouteConfig
11+
{
12+
public static void RegisterRoutes(RouteCollection routes)
13+
{
14+
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
15+
16+
routes.MapRoute(
17+
name: "Default",
18+
url: "{controller}/{action}/{id}",
19+
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
20+
);
21+
}
22+
}
23+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Microsoft.AspNet.Identity;
5+
using Microsoft.AspNet.Identity.EntityFramework;
6+
using Microsoft.Owin;
7+
using Microsoft.Owin.Security.Cookies;
8+
using Microsoft.Owin.Security.Google;
9+
using Microsoft.Owin.Security.OAuth;
10+
using Owin;
11+
using WebAPIExample.Providers;
12+
using WebAPIExample.Models;
13+
14+
namespace WebAPIExample
15+
{
16+
public partial class Startup
17+
{
18+
public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; }
19+
20+
public static string PublicClientId { get; private set; }
21+
22+
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
23+
public void ConfigureAuth(IAppBuilder app)
24+
{
25+
// Configure the db context and user manager to use a single instance per request
26+
app.CreatePerOwinContext(ApplicationDbContext.Create);
27+
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
28+
29+
// Enable the application to use a cookie to store information for the signed in user
30+
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
31+
app.UseCookieAuthentication(new CookieAuthenticationOptions());
32+
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
33+
34+
// Configure the application for OAuth based flow
35+
PublicClientId = "self";
36+
OAuthOptions = new OAuthAuthorizationServerOptions
37+
{
38+
TokenEndpointPath = new PathString("/Token"),
39+
Provider = new ApplicationOAuthProvider(PublicClientId),
40+
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
41+
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
42+
// In production mode set AllowInsecureHttp = false
43+
AllowInsecureHttp = true
44+
};
45+
46+
// Enable the application to use bearer tokens to authenticate users
47+
app.UseOAuthBearerTokens(OAuthOptions);
48+
49+
// Uncomment the following lines to enable logging in with third party login providers
50+
//app.UseMicrosoftAccountAuthentication(
51+
// clientId: "",
52+
// clientSecret: "");
53+
54+
//app.UseTwitterAuthentication(
55+
// consumerKey: "",
56+
// consumerSecret: "");
57+
58+
//app.UseFacebookAuthentication(
59+
// appId: "",
60+
// appSecret: "");
61+
62+
//app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
63+
//{
64+
// ClientId = "",
65+
// ClientSecret = ""
66+
//});
67+
}
68+
}
69+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Net.Http;
5+
using System.Web.Http;
6+
using Microsoft.Owin.Security.OAuth;
7+
using Newtonsoft.Json.Serialization;
8+
using WebAPIExample.Controllers;
9+
10+
namespace WebAPIExample
11+
{
12+
public static class WebApiConfig
13+
{
14+
public static void Register(HttpConfiguration config)
15+
{
16+
// Web API configuration and services
17+
// Configure Web API to use only bearer token authentication.
18+
config.SuppressDefaultHostAuthentication();
19+
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
20+
21+
// Web API routes
22+
config.MapHttpAttributeRoutes();
23+
24+
config.Routes.MapHttpRoute(
25+
name: "DefaultApi",
26+
routeTemplate: "api/{controller}/{id}",
27+
defaults: new { id = RouteParameter.Optional }
28+
);
29+
30+
//add the handler class in WebApiConfig
31+
config.MessageHandlers.Add(new APIKeyHandler());
32+
}
33+
}
34+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Text;
3+
using System.Web;
4+
using System.Web.Http.Description;
5+
6+
namespace WebAPIExample.Areas.HelpPage
7+
{
8+
public static class ApiDescriptionExtensions
9+
{
10+
/// <summary>
11+
/// Generates an URI-friendly ID for the <see cref="ApiDescription"/>. E.g. "Get-Values-id_name" instead of "GetValues/{id}?name={name}"
12+
/// </summary>
13+
/// <param name="description">The <see cref="ApiDescription"/>.</param>
14+
/// <returns>The ID as a string.</returns>
15+
public static string GetFriendlyId(this ApiDescription description)
16+
{
17+
string path = description.RelativePath;
18+
string[] urlParts = path.Split('?');
19+
string localPath = urlParts[0];
20+
string queryKeyString = null;
21+
if (urlParts.Length > 1)
22+
{
23+
string query = urlParts[1];
24+
string[] queryKeys = HttpUtility.ParseQueryString(query).AllKeys;
25+
queryKeyString = String.Join("_", queryKeys);
26+
}
27+
28+
StringBuilder friendlyPath = new StringBuilder();
29+
friendlyPath.AppendFormat("{0}-{1}",
30+
description.HttpMethod.Method,
31+
localPath.Replace("/", "-").Replace("{", String.Empty).Replace("}", String.Empty));
32+
if (queryKeyString != null)
33+
{
34+
friendlyPath.AppendFormat("_{0}", queryKeyString.Replace('.', '-'));
35+
}
36+
return friendlyPath.ToString();
37+
}
38+
}
39+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /