In ios does the generated ViewController represent a part of the view or the controller if you are working in mvc? This guy over here believes it’s a part of the view https://www.raywenderlich.com/132662/mvc-in-ios-a-modern-approach While lynda instructors beleive it’s in the control? How should I believe?

I have returned a list of data to a view and im looking to return a second set of data based on a user selected id from that list and filter by 2 textbox user input from and to dates.  Without the from and to date i have done this using

View

@model IEnumerable<DAL.Person>

@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.GivenName)
</td>
<td>
@Html.DisplayFor(modelItem => item.FamilyName)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateOfBirth)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
@Html.DisplayFor(modelItem => item.PostCode)
</td>
<td>
<div class="ExtractDocs">
@Html.ActionLink("Extract", "GetData", "Home", new { id = item.PersonID }, new { onclick = "DisplayProgressMessage();" })
</div>
</td>
</tr>
}

Controller

  public ActionResult GetData(int id)
{

Now i want to filter 'GetData' by passing a From and To Date

Tested this using the below and adding a new route for it in RouteConfig.

@Html.ActionLink("Extract", "GetData", "Home", new { id = item.PersonID, fromdate = "30/01/2018", todate = "27/04/2018" }, new { onclick = "DisplayProgressMessage();" })

This works but i now need two textbox datepickers that i need to pass the data to the controller to filter the data.

@Html.TextBox("DateFrom", String.Format("{0:dd/MM/yyyy}", ""), new { @class = "datepicker" })
@Html.TextBox("DateTo", String.Format("{0:dd/MM/yyyy}", ""), new { @class = "datepicker" })

Is there a way to get the values from the user input text boxes to pass in the actionlink along with the id from the Model item on the specific row.

Thanks

First time posting here and also pretty new at everything to put it bluntly. I'm making an application at work (apprenticeship) which requires sending some feedback to an employee and it all being stored. My employee database is all set up and I can search for employees, click on their name and a feedback form comes up. Brilliant.

My question is at the moment whatever employee is clicked on an empty feedback form comes up but I would ideally like is the recipient already filled in once clicked on his/her name.

Sorry I'm pretty bland, What sort of code would be worth while you seeing in order to possibly help me. I'm not sure if it was a simple fix or you would need to see some more in-depth code.

I've searched online but couldn't find anything I felt like I could apply to what's already in place, and some were really advanced it looked like.

Thanks for any responses, I know there is not much to go on, but it can be provided once I know what's needed.

I'm trying to create a little search bar on my website with symfony 4. How do I get the the user input data from the form which can be used in the controller. The form looks like this :

 //.../navbar.html.twig

<form action="search" method="get" >
<input type="text" placeholder="Search..">
<button type="submit" class="btn btn-default">Search</button>
</form>

I have been struggling the past few days with getting Rotativa working the way I want it to. I'm developing an ASP.NET MVC core application but I'm really not experienced in it. I have a view in which google charts are being shown. I want that page to be able to be printed as an pdf. The view contains tables as well though, which need to be in the pdf as well (so I can't just add the charts as images to a .pdf file). Getting the charts to show up was already a challenge. But that I managed with the "--window-status ready" parameter and a little function in my view. But now all my graphs show up half the size that they usually are. And with everything I try one of two things happen. The browser just keeps on loading and never shows the pdf or the width of my graphs does not change at all. My code seems a bit to long of the view to post here so I used some site to share it: https://codepad.co/snippet/AjY4m7BZ . If you need any more code, feel free to ask for it. I hope someone can help me. Because so far the internet hasn't been of much help.( I removed the tables from the code snippet btw to de-clutter the code a bit)

I have class which help to convert usd to inr now which are giving error now which is this:

Specified argument was out of the range of valid values.

On this line code line:

var result = Regex.Matches(streamReader.ReadToEnd(), "<span class=\"?bld\"?>([^<]+)</span>")[0].Groups[1]

Here is a full class:

public static decimal CurrencyConvert(decimal amount, string fromCurrency, string toCurrency)
{
     //Grab your values and build your Web Request to the API
     string apiURL = String.Format("http://finance.google.com/finance/converter?a={0}&from={1}&to={2}&meta={3}", amount, fromCurrency, toCurrency, Guid.NewGuid().ToString());
     //Make your Web Request and grab the results
     var request = WebRequest.Create(apiURL);         
     //Get the Response
     var streamReader = new StreamReader(request.GetResponse().GetResponseStream(), Encoding.ASCII);
     //Grab your converted value (ie 2.45 USD)
     var streamData = streamReader.ReadToEnd();
     var result = Regex.Matches(streamData, "<span class=\"?bld\"?>([^<]+)</span>")[0].Groups[1].Value;
     //Get the Result
     return Convert.ToDecimal(result.Replace(" INR", ""));
}

I've created an MVC project and added the functionality which allows users to log in with 3rd party login providers (Twitter, Google, Facebook and Microsoft). I kept receiving an error so i added a breakpoint and a string[] of Errors showed the error "A user with that external login already exists.". To my understanding, this is an identity error, however, I'm unable to find where this string[] is. A friend told me to look at resource.resx file but that is nowhere to be found in my solution. Any help on where I can find the errors?

Also, I've tried handling the error like this:

public enum ManageMessageId
    {
        AddPhoneSuccess,
        ChangePasswordSuccess,
        SetTwoFactorSuccess,
        SetPasswordSuccess,
        RemoveLoginSuccess,
        RemovePhoneSuccess,
        Error,
        EmailExists
    }


public async Task<ActionResult> Index(ManageMessageId? message)
    {
        ViewBag.StatusMessage =
            message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
            : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
            : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
            : message == ManageMessageId.Error ? "An error has occurred."
            : message == ManageMessageId.EmailExists ? "An account with that email already exists!"
            : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
            : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
            : "";

        var userId = User.Identity.GetUserId();
        var model = new IndexViewModel
        {
            HasPassword = HasPassword(),
            PhoneNumber = await UserManager.GetPhoneNumberAsync(userId),
            TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId),
            Logins = await UserManager.GetLoginsAsync(userId),
            BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId)
        };
        return View(model);


public async Task<ActionResult> LinkLoginCallback()
    {
        var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(XsrfKey, User.Identity.GetUserId());
        if (loginInfo == null)
        {
            return RedirectToAction("ManageLogins", new { Message = ManageMessageId.Error });
        }
        var result = await UserManager.AddLoginAsync(User.Identity.GetUserId(), loginInfo.Login);
        if (result.Succeeded)
        {
            return RedirectToAction("ManageLogins");
        }
        else
        {
            var errorMessage = result.Errors.First();
            if (errorMessage.Equals("A user with that external login already exists.", StringComparison.InvariantCultureIgnoreCase))
            {
                 return RedirectToAction("ManageLogins", new { Message = ManageMessageId.EmailExists });
            }
            else
            {
                return RedirectToAction("ManageLogins", new { Message = ManageMessageId.Error });
            }
        }
        }
}

I'm unsure as to whether this handles the error properly. Any weakpoints?

I want to upload and save a file along with other user input data having datatype int,string and datetime. I would like save the file to the hard-drive and save the path and other input data in the SQL Server database table. I am getting AggregateException whenever I am trying to do both together. I am new to ASP.NET MVC and Web API. Kindly help.

Below is my action method in ASP.NET MVC project.

public ActionResult AddOrEdit(mvcCandidate cn)
{
    if (cn.ID == 0)
    {
        if (cn.cvFile.ContentLength != 0)
        {
            string filename = Path.GetFileNameWithoutExtension(cn.cvFile.FileName);
            string extension = Path.GetExtension(cn.cvFile.FileName);
            filename = filename + DateTime.Now.ToString("yymmssff") + extension;
            cn.path = "~/Uploads/" + filename;
            filename = Path.Combine(Server.MapPath("~/Uploads/"), filename);
            cn.cvFile.SaveAs(filename);
        }
        else
            cn.path = "";
        try
        {
            HttpResponseMessage response = GlobalVariables.WebApiClient.PostAsJsonAsync("Candidates", cn).Result;
        }
        catch (AggregateException ex)
        {
            var ch = ex.Message;
            return null;
        }         
    }
}

And this is the action method in WebAPI project

public IHttpActionResult PostCandidate(Candidate candidate)
{
    db.Candidates.Add(candidate);
    db.SaveChanges();
    return CreatedAtRoute("DefaultApi", new { id = candidate.ID }, candidate);
}

The model class is as below:

public class mvcCandidate
{
    public int ID { get; set; }
    [Display(Name="Name")]
    public string Name { get; set; }
    [Display(Name = "Address")]
    public string Adress { get; set; }    
    [Display(Name = "Date Of Birth")]
    [DataType(DataType.Date)]
    public Nullable<System.DateTime> DOB { get; set; }
    public string PIN { get; set; }
    public Nullable<int> CompanyID { get; set; }
    [Display(Name = "CV")]
    public string path { get; set; }
    public HttpPostedFileBase cvFile { get; set; }           
    public virtual mvcCompany Company { get; set; }
}

I appear to be having a problem getting the menu to show up on a fresh install of bootstrap in ASP.Net MVC.

When I create a new project, I can test it and it shows the menu at the top. I then install bootstrap via the Package Manager Console with the command Install-Package bootstrap (which installs 4.1.0 but I've also tried using -Version 4.0.0)

When I then test the code, the area for the menu only shows "Application Name", the menu itself does not appear, and when resizing the window to a small width, no menu button appears at the top right either.

The only thing I note is that when installing, there is an error during the installation with:

Executing script file '...\visual studio 2017\Projects\WebApplication5\packages\jQuery.3.0.0\tools\install.ps1'

Cannot index into a null array.

At ...\documents\visual studio 2017\Projects\WebApplication5\packages\jQuery.3.0.0\tools\common.ps1:105 char:1

I assume that this file came pre-installed with Microsoft Visual Studio so that's probably a red-herring.

Any suggestions on how I can get the menu on a bootstrap template to work?

ASP.Net Core 2: I am using windows authentication on local IIS.
UserPrincipal.Current returns app pool service account.
User.Identity.Name returns null.
Here is the web config:

    <system.web>
       <authentication mode="Windows"></authentication>
       <authorization>
          <deny users="?" />
       </authorization>
       <identity impersonate="false" />
    </system.web>

I tried using impersonate = true as well. But it didn't help.

Only windows authentication enabled in IIS

If I have an nodejs express application with folowing folder structure:

-src - client - public - css - js - ... - views - server - server.js

  • How can I serve the static files in the public folder from the server.js file, since it is located above the index.js root location?
  • How should the:

app.use(express.static();

look like?

A registered user can create a post and with that post, a user can upload multiple pictures. However the issue I am having is that it fails to validate the file upload correctly. I used:

mimes:jpg,jpeg,png

However, when I upload images that are those types it says they are not. Before implementing multiple image upload I had 1 image upload in place and it was fine, but when I made it multiple images it broke it.

Here is my postController.php method for creating a post:

public function postCreatePost(Request $request){
   //validates each field 
    $this->validate($request, [
        'title' => 'required|max:100',
        'type' => 'required',
        'subtype' => 'required|max:100',
        'date' => 'required|date',
        'venue' => 'required|max:100',
        'body' => 'required',
        'cover_image' => 'required|mimes:jpeg,jpg,png'
    ]);

    //adds each field sent in the request to the relevant post table column
    $post = new Post(); 
    $post->title = $request['title'];
    $post->type = $request['type'];
    $post->subtype = $request['subtype'];
    $post->date = $request['date'];
    $post->venue = $request['venue'];
    $post->body = $request['body'];



    $message = 'There was an error';
    if($request->user()->posts($post)->save($post)){ //submits record to post table and if succesful it will enter loop

        //creats image name and stores it in images table and stores the image in the cover_images directory
        if($request->hasFile('cover_image')){
            foreach($request->file('cover_image') as $file){
                $filenameWithExt = $file->getClientOriginalName();
                $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
                $extension = $file->getClientOriginalExtension();
                $fileNameToStore = $filename . '_' . time() . '.' . $extension; 
                $path = $file->storeAs('public/cover_images', $fileNameToStore);
                $image = new Image();
                $image->cover_image = $fileNameToStore;
                $image->post_id = $post->id;
                $image->save();
            }
        }

        $message = 'post successfully created';
    }

    return redirect()->route('dashboard')->with(['message' => $message]); // redirects user back to the dashboard
}

I have returned a list of data to a view and im looking to return a second set of data based on a user selected id from that list and filter by 2 textbox user input from and to dates.  Without the from and to date i have done this using

View

@model IEnumerable<DAL.Person>

@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.GivenName)
</td>
<td>
@Html.DisplayFor(modelItem => item.FamilyName)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateOfBirth)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
@Html.DisplayFor(modelItem => item.PostCode)
</td>
<td>
<div class="ExtractDocs">
@Html.ActionLink("Extract", "GetData", "Home", new { id = item.PersonID }, new { onclick = "DisplayProgressMessage();" })
</div>
</td>
</tr>
}

Controller

  public ActionResult GetData(int id)
{

Now i want to filter 'GetData' by passing a From and To Date

Tested this using the below and adding a new route for it in RouteConfig.

@Html.ActionLink("Extract", "GetData", "Home", new { id = item.PersonID, fromdate = "30/01/2018", todate = "27/04/2018" }, new { onclick = "DisplayProgressMessage();" })

This works but i now need two textbox datepickers that i need to pass the data to the controller to filter the data.

@Html.TextBox("DateFrom", String.Format("{0:dd/MM/yyyy}", ""), new { @class = "datepicker" })
@Html.TextBox("DateTo", String.Format("{0:dd/MM/yyyy}", ""), new { @class = "datepicker" })

Is there a way to get the values from the user input text boxes to pass in the actionlink along with the id from the Model item on the specific row.

Thanks

I have a project where I am passing the data from C# to cshtml by something like this:

public IActionResult Index()
    {
        ViewData["temp"] = "abc"
        return View();
    }

This value is then received in the cshtml file where I can read this as

var temp = ViewData["temp"];

I have a typescript file that is then booted from this cshtml file. My question is, how can I use this temp variable in my typescript code. I don't want to create a 'div' element for this temp data and then read its value in typescript as this will not be a clean thing to do from security perspective.

Can you please suggest some way to do it in a proper way?

I have class which help to convert usd to inr now which are giving error now which is this:

Specified argument was out of the range of valid values.

On this line code line:

var result = Regex.Matches(streamReader.ReadToEnd(), "<span class=\"?bld\"?>([^<]+)</span>")[0].Groups[1]

Here is a full class:

public static decimal CurrencyConvert(decimal amount, string fromCurrency, string toCurrency)
{
     //Grab your values and build your Web Request to the API
     string apiURL = String.Format("http://finance.google.com/finance/converter?a={0}&from={1}&to={2}&meta={3}", amount, fromCurrency, toCurrency, Guid.NewGuid().ToString());
     //Make your Web Request and grab the results
     var request = WebRequest.Create(apiURL);         
     //Get the Response
     var streamReader = new StreamReader(request.GetResponse().GetResponseStream(), Encoding.ASCII);
     //Grab your converted value (ie 2.45 USD)
     var streamData = streamReader.ReadToEnd();
     var result = Regex.Matches(streamData, "<span class=\"?bld\"?>([^<]+)</span>")[0].Groups[1].Value;
     //Get the Result
     return Convert.ToDecimal(result.Replace(" INR", ""));
}

I want to show all the values of my list(strings) to a razor view but without using a "foreach" method.

I've got this but the only thig remaining to show is a List<Answer>.

@model PoolManager.Models.Question

@{
    ViewData["Title"] = "Details";
}

<h2>Details</h2>

<table class="table">
    <thead>
        <tr class="bg-primary">
            <th>Question</th>
            <th>Answers</th>
            <th>Starting Date</th>
            <th>Ending Date</th>
            <th>Active</th>
            <th>Details</th>
            <th>Edit</th>
            <th>Delete</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td class="bg-info">@Model.Text</td>    
            <td class="bg-info">@Model.StartDate</td>
            <td class="bg-info">@Model.EndDate</td>
            <td></td>
                <a asp-action="Edit" asp-route-id="@Model">Edit</a> |
                <a asp-action="Details" asp-route-id="@Model.Id">Details</a> |
                <a asp-action="Delete" asp-route-id="@Model.Id">Delete</a>
            </td>
        </tr>
    </tbody>
</table>

I have this until now but it's only counting the number of the answers, but I need to output the answer not the id of it.

  @for (int i = Model.Answers.Count; i >= 0; i--)
  {          
      String Resposta = Model.Answers.ToString();

      <td class="bg-info" @Resposta></td>
  }

The output im getting is:

system.collections.generic.list`1[poolmanager.models.answer]

I’m hoping that someone will be able to help we with an IIS / ASP.NET issue that I’m having. I’ve been tasked with moving an ASP.NET website from IIS 6 on a Windows 2003 32-bit server to IIS 10 on a Windows 2016 64-bit server. I’ve installed IIS and the .NET 3.5 Framework which includes .NET 2.0 and 3.0 using PowerShell with the following features

$featureList = @('Web-Server','Web-CertProvider','Web-IP-Security','Web-Windows-Auth','Web-Asp-Net', 'NET-Framework-Features')
Install-WindowsFeature -Name $installFeatures -IncludeManagementTools -Source 'D:\sources\sxs' -Restart

Next created my application pool and site as follows

New-WebAppPool -Name 'MyApp_AppPool'
Get-Item -Path 'IIS:\AppPools\MyApp_AppPool' | Set-ItemProperty -Name managedRuntimeVersion -Value 'v2.0'
New-Website -Name MyApp -ApplicationPool MyApp_AppPool -HostHeader myapp.domain.ca -IPAddress * -PhysicalPath 'E:\inetpub\wwwroot\MyApp' -Port 80

The site seems to load the login page, however in IIS Manager, if I go to .NET Compilation I receive the following error message. There was an error while performing this operation.

Details:
Filename: \\?\E:\inetpub\wwwroot\PEIWeb\web.config
Line number: 25
Error: Unrecognized element ‘compilers’

Here is an exert for the web.config file

    <compilation defaultLanguage="vb" debug="true">
        <compilers>
            <compiler language="vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" extension=".VB" compilerOptions="/define:Debug=True /define:Trace=True /imports:Microsoft.VisualBasic,System,System.Collections,System.Configuration,System.Data,System.Drawing,System.Web,System.Web.UI,System.Web.UI.HtmlControls,System.Web.UI.WebControls" />
        </compilers>
        <assemblies>
            <add assembly="Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
            <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        </assemblies>
    </compilation>

I have tested the Application Pool with the managed pipeline mode set to Integrated and Classic, and have also test setting Enable 32-Bit Applications to True, but I still get the same error.

I read online that is possible to get this type of error if IIS is installed before installing .NET 3.5 Framework, so I uninstalled both using server manager rebooted, the installed .NET 3.5 Framework and rebooted and installed IIS, but I still get the same error.

I’ve also tried running aspnet_regiis.exe -i from the two following folders, but again I still received the same error.

C:\Windows\Microsoft.NET\Framework\v2.0.50727 C:\Windows\Microsoft.NET\Framework64\v2.0.50727

If anyone has any suggestions on how to correct this issue i would be really gratefull.

Thanks

I would like to ask for advice. I use ckfinder to upload files. However, I need to check if the file is somewhere used before renaming, deleting, or moving file to another directory.

Typical use:

  1. File's upload - without any save in db
  2. Select the file
  3. Store file information in DB
  4. Linking with content in database (not a ckeditor) as attachment

The problem is when a user wants to change the name of a file in ckfinder or delete a file, then I need to check if the file is somewhere in use. And stop him from doing so.

onInit: function (finder) {

    finder.on('command:before', function (evt) {

        if (evt.data.name == "RenameFile") {
            var dir = evt.data.folder.attributes.path + evt.data.folder.attributes.name + '/';

            console.log('Rename: Old file name=' + dir + evt.data.params.fileName + ' , new file name:' + dir + evt.data.params.newFileName);
            //BackEnd test if file is used. Returns true if is free for changes, or false in file is somewhere used. 
            if(GetFileUsage(evt.data.params.fileName,evt.data.folder.getPath())){
                console.log('GetFileUsage - true');
            }
            else{
                console.log('GetFileUsage - false');
                //if file is used, then cancel event
                event.cancel();
            }

        }

    }, null, null, 1); // Assign high priority
    finder.on('command:after', function (evt) {

        if (evt.data.name == "RenameFile") {
            var dir = evt.data.response.currentFolder.path + '/';

            console.log('After Rename: Old file=' + dir + evt.data.response.name + ' , new file:' + dir + evt.data.response.newName);
            //
        }


    }, null, null, 1); // Assign high priority

}

But the function GetFileUsage() uses $.ajax and the ckfinder event simply does not wait on response and rename file.

Any idea how to prevent it?

Edit: I know that ajax is asynchronous. I also understand why this is happening. I just can not figure out how to do what I need.

I have a RowCommande event that gets fired when i press "select" link on my gridview.

My problem occured when i created the DDL header in my gridview, I get an empty row (or rather the ListItem value) in my code.

This code worked before i created my HeaderTemplate

 protected void gwActivity_RowCommand(object sender, GridViewCommandEventArgs e)
    {

    GridViewRow row = ((e.CommandSource as Control).NamingContainer as GridViewRow);

        if (!string.IsNullOrEmpty(row.Cells[2].Text) && row.Cells[2].Text != "&nbsp;")
        {
            txtActivity.Text = row.Cells[2].Text;
        }
        else
        {
            txtActivity.Text = string.Empty;
        }

}

I can´t seem to understand why?

I know this has been asked several times but I don't quite understand why it affects my project.

The project is an ASP.NET MVC Web App targeting the .NET Framework 4.6.1.

All of a sudden (some NuGet packages were upgraded) I started to get the following error during runtime:

CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

In my main view Index.cshtml, in a line where I make use of @Html.ActionLink

I do have .NET Core SDK 2.0 and .NET Framework 4.71 installed in my machine but I don't want to include a reference to it. This is a .NET Framework web app only, it's hosted on Windows IIS where the installed framework is 4.6.1, there's no NET Core installed in the server.

So why is it asking to add a reference to netstandard? How can I fix it without referencing netstandard but the full Windows .NET Framework 4.6.1?

EDIT

I've checked out a previous commit which worked fine and I'm still getting this error. So it's not related to NuGet packages being upgraded. Seems to be something on my local dev machine.

EDIT 2

If a publish the app to a directory and run it with IIS it works.

Link to .csproj gist

I have an mvc5 application that I want to allow for two different authentication options to take place.

For users within the company, I want to authenticate against Azure AD using OpenId. I have this piece working correctly.

            app.UseOpenIdConnectAuthentication(
            new OpenIdConnectAuthenticationOptions
            {
                ClientId = clientId,
                Authority = authority,
                PostLogoutRedirectUri = postLogoutRedirectUri,
                RedirectUri = postLogoutRedirectUri,
                Notifications = new OpenIdConnectAuthenticationNotifications
                {
                    AuthenticationFailed = context =>
                    {
                        context.HandleResponse();
                        context.Response.Redirect("/Error?message=" + context.Exception.Message);
                        return Task.FromResult(0);
                    }
                }
            });

For external users, I want to have a separate login page for them, where they can input a userId/password, and use basic CookieAuthentication to authenticate.

app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),
            ExpireTimeSpan = System.TimeSpan.FromMinutes(60),
            SlidingExpiration = true,
            Provider = new CookieAuthenticationProvider
            {
                OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, User, int>(
                       validateInterval: TimeSpan.FromMinutes(30),
                       regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager),
                       getUserIdCallback: id => id.GetUserId<int>()),

            }
        });

Ideally, on my controllers, I could tag them with an implementation of the AuthorizeFilter that would handle either user case -- my thought is on the database, I would have a central user database that includes AD and External users, so that I can create a role/permissions structure that is common to both. Ideally the only piece that would be different is the path to initial authentication, and after that, I could authorize very similarly.

I have implemented both of these auth flows before separately, but not sure how to offer them simultaneously, while minimizing code duplication on the authentication piece.