© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
53 replies
hellounlimited

✅ oauth in asp net framework?

hi all, i have created a redirect url for oauth clients

how can i redirect my deployed asp net project in iis to redirect to do the authentication?

this is then authentication controller

public class AuthController : Controller
{
public ActionResult Index()
{
return View();
}

[Route("auth/redirect")]
[HttpGet]
public ActionResult Redirect()
{
string redirectScript = "<html><script>window.location.href=window.location.href.Replace('#', '?').Replace('redirect', 'AuthRedirect')</script></html>";
return Content(redirectScript, "text/html");
}

[HttpGet]
public ActionResult AuthRedirect(string access_token)
{
// Get the full URL from the request
var url = Request.Url.ToString();

// Extract the fragment identifier
var fragment = url.Substring(url.IndexOf('#') + 1);

// Parse the fragment to extract the access_token parameter value
var queryString = HttpUtility.ParseQueryString(fragment);
var accessToken = queryString["access_token"];

var cookie = new HttpCookie("otsession", accessToken)
{
Path = "/",
HttpOnly = true,
};

Response.Cookies.Add(cookie);

return RedirectToAction("Index", "Home");
}
}

this is the oauth link http://localhost:8080/otdsws/login?response_type=token&client_id=<oauth client ID>&redirect_uri=<successful authentication redirect url>&state=none

i have never created an implementation of oauth before.. so any assistance will be appreciated
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

❔ ASP.NET Core web app vs ASP.net web application(.NET Framework)
C#CC# / help
4y ago
❔ Sitecore using C# ASP.net Framework
C#CC# / help
3y ago
automapper in net framework
C#CC# / help
4y ago
Logging in ASP.NET
C#CC# / help
2y ago