Can someone maybe give me a nudge in the right direction?
Thanks!
never mind
I want to print a .pdf file in server-side (api or mvc).
I have tried to research but can not find any solution.
I need a solution, please.
The idea of the code below is to extract build timestamp from PE-compatible EXE or DLL. The code works perfectly for .NET binaries (for >6 years by now, btw) and reports rubbish for .NET Core ones. For a freshly built .NET (not Core) assembly it (correctly) reports "Mon Oct 9 13:30:14 2017", for a freshly built .NET Core v.2 assembly it reports "Tue Mar 29 05:14:00 2061" (?).
It means that .NET Core assemblies do not follow PE file format _exactly_. In .NET Core case the timestamp field of IMAGE_FILE_HEADER does not contain "The low 32 bits of the number of seconds since 00:00 January 1, 1970 (a C run-time time_t value), that indicates when the file was created" (quote from pecoff.docx) as it should.
I received an answer: "this is really a change by the roslyn compilers. see: https://github.com/dotnet/roslyn/issues/5940".
Three questions in this regard:
(1) Why would roslyn change PE format (that is, if it did, see next question)?
(2) If roslyn did change PE format, why does the change show itself in .NET Core builds ONLY, but not in .NET builds (VS 2015 certainly uses roslyn for both .NET Core and .NET builds)? Are there two flavors of roslyn (a joke)?
(3) Ok, let it be, but where _is_ the build timestamp in a binary built in .NET Core 2.0 environment?
// per "Microsoft PE and COFF Specification" pecoff_v8.docx at (as of 06/18/11)// http://msdn.microsoft.com/en-us/windows/hardware/gg463125// or, as of Oct 9th, 2017, pecoff.docx available at// https://www.microsoft.com/en-us/download/confirmation.aspx?id=19509constlong c_offsetOfOffsetOfPE =0x3c;// per section 2 of pecoff_v8.docxconstInt32 c_PE00 =0x00004550;// = 50 45 00 00 = PE\0\0/// <summary>/// Extracts build time from a PE executable (EXE or DLL) per "Microsoft PE and COFF Specification" pecoff_v8.docx/// </summary>staticDateTimeGetExeOrDll_EST_TimeStampDT(){DateTime timeStamp =newDateTime();try{// This works OK for .NET but produces invalid timestamp for .NET Core assemblies(why ?)string path =MyAssembly.Location;using(FileStream fs =newFileStream(path,FileMode.Open,FileAccess.Read,FileShare.ReadWrite)){using(BinaryReader br =newBinaryReader(fs)){ fs.Position= c_offsetOfOffsetOfPE;byteOffsetOfPE= br.ReadByte();// = 0x80 fs.Position=OffsetOfPE;Int32 PE00 = br.ReadInt32();// = 0x00004550 [ = 50 45 00 00 = PE\0\0 ]if(PE00 != c_PE00){return timeStamp;}// invalid file format, return "best guess" (last write time) fs.Position=OffsetOfPE+8;UInt32 timeStampLower32Bits = br.ReadUInt32();// .ReadInt32(); // = 0x4dfcd934if(timeStampLower32Bits ==0|| timeStampLower32Bits ==0xFFFFFFFF){return timeStamp;}// invalid date/time stamp, return "best guess" (last write time) timeStamp =newDateTime(1970,1,1,0,0,0,DateTimeKind.Utc);// 00:00 January 1, 1970 (a C run-time time_t value) timeStamp = timeStamp.AddSeconds(timeStampLower32Bits);TimeZoneInfo easternStdTime =TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"); timeStamp =TimeZoneInfo.ConvertTimeFromUtc(timeStamp, easternStdTime);}}}catch(Exception ex){string qqq = ex.Message;}return timeStamp;
}
Is Entity Framework 6 usable in .NET Standard 2.0?
Hi
I'm working on an ASP Core 2.0 project that contains in the same controller both API actions returning JSON and actions returning views for simplicity.
I implemented the dual auth considering the following blog :
https://wildermuth.com/2017/08/19/Two-AuthorizationSchemes-in-ASP-NET-Core-2
It works, but because of my mixing API/actions for views in the same controller, If I have such a controller :
[Authorize] public class AccountController : Controller { ... [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] public IActionResult Get() { return Ok(new[] { "One", "Two", "Three" }); } }
then the Get Action needs both a Cookie Auth and a JWT bearer token auth to be authorized.
I would like to separate :
Autorize with cookies for actions for views and JWT bearer auth for API, not a cumulative auth.
Here is my startup.cs code (method ConfigureServices):
// Enable Dual Authentication services.AddAuthentication() .AddCookie(cfg => cfg.SlidingExpiration = true) .AddJwtBearer(cfg => { cfg.RequireHttpsMetadata = false; cfg.SaveToken = true; cfg.TokenValidationParameters = new TokenValidationParameters() { ValidIssuer = Configuration["Tokens:Issuer"], ValidAudience = Configuration["Tokens:Audience"], IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Tokens:Key"])) }; });
I managed to make it work separately if I don't use the Authorize globally on the Controller, but on each Action instead.
But I would like to find a way to keep my [Authorize] globally and specify for each needed API actions the JWT bearer auth [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] and only it.
Is there a way to do this ?
Many thanks
Hi all,
I use VS2017 to create ASP.NET Core 2.0 web application, and I select Angular template, but the generated project still contains razor view, why? Any blog or articles can anylize the project's structure and how the client side and server side code organized?
I have Core Web app in a Service Fabric service running, single node. It uses AzureAD for authentication. This works fine, the AzureApp hashttps://localhost:12345/signin-oidc as reply Url defined and the app is running on that port.
Now we modified this service, allowing it to run on multiple nodes and without a fixed port number. So it is running on 5 nodes under different port numbers. And we do not really know up front what portnumbers. We have another node that acts as a gateway and it is running on and https://localhost:12345 and forwards the requests to the other 5 nodes.
The problem is that after the user logged in in Azure we get an error like
AADSTS50011: The reply address 'http://localhost:31001/signin-oidc' does not match the reply addresses configured for the application: xxxxxxxxxxxxxxxxxxx'. |
So how can we set the Reply URL to a fixed value?
I was expecting I could do something with the OnRedirectToIdentityProvider event, but it is never reached.
Surprising as the documentation states 'Invoked before redirecting to the identity provider to authenticate', I would expect to hit it BEFORE I go to the login page.
Thanks
Ben
</div>
Not sure why this is happening but whenever I run my app now in Visual Studio the angular app doesn't work and if I look in Chrome dev tools I see things like :
http://localhost:65159/counter.component.html 404 (Not Found)
So its looking in the wrong place for the angular component.html files, this has previously worked.
Can anyone help?
Hi there,
I wondered if someone would be able to advise on a course of action for an error I'm getting when adding a Migration.
I add a class called Country containing the following properties:
public int CountryId { get; set; } public string CountryName { get; set; }
I add two properties to the default ApplicationUser.cs file:
public DateTime DateOfBirth { get; set; } public Country Country { get; set; }
I then go to do the migration in the PMC console:
Add-Migration date_name
However, it comes back with the following error:
An error occurred while calling method 'BuildWebHost' on class 'Program'. Continuing without the application service provider. Error: One or more errors occurred. (Invalid column name 'CountryId'. Invalid column name 'DateOfBirth'.) Unable to create an object of type 'ApplicationDbContext'. Add an implementation of 'IDesignTimeDbContextFactory<ApplicationDbContext>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.
I have googled and found answers, however, they all relate to migrating from Core 1 to 2. I've compared the 'solutions' and my code seems fine.
If I remove the two properties from the ApplicationUser class then Migrations work again!
Can anyone advise on a solution, please?
Regards,
Dave.
Hi,
Just started working on .net core. I have created a project using .net core. Now I want to implement forms authentication. So looking for any inputs of how to integrate forms authentication in .net core. In our previous asp.net mvc application we used to do asp.net identity. Does the same applies here or if authentication is different here. We want to have a login page where the user enters there Active directory user name and password.
Now on Authorization, once the user is successfully authenticated above we have about certain users that have admin access vs some which have read only. We have table having username and permission against it. On successful authentication I want to check my sql table whether they have appropriate role to access certain functionality on our site or not. I can do so by creating an attribute and have it placed over the controller. But what if I need it on granular level like dropdown, restricting delete on a grid, hiding some functionality. What is the best way to approach this. .net Core, MVC, C#, Sql Server
Thanks
SignInManager<ApplicationUser>.GetExternalLoginInfoAsync returns null. I am not sure why. I am trying to retrieve the same"userId" (user-defined) that I stored in the cache via "OnAuthorizationCodeReceived":
public async Task OnAuthorizationCodeReceived(AuthorizationCodeReceivedContext context) { // string userId = context.Ticket.Principal.FindFirst(ClaimTypes.NameIdentifier).Value; // string userId = context.HttpContext.User.Identity.Name; string userId = context.Principal. FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; // Use MSAL to swap the code for an access token // Extract the code from the response notification string code = context.ProtocolMessage.Code; TokenCache tokenCache = new SessionTokenCache(userId, context.HttpContext).GetMsalCacheInstance(); ClientCredential clientCred = new ClientCredential(azureadclientsecret); ConfidentialClientApplication cca = new ConfidentialClientApplication(azureadclientid, string.Format(CultureInfo.InvariantCulture, azureadaadinstance, "common", "/v2.0"), oauth2redirecturi, clientCred, tokenCache, null); try { AuthenticationResult result = await cca.AcquireTokenByAuthorizationCodeAsync(code, oauth2appscopes.Split(' ')); context.HandleCodeRedemption(result.AccessToken, result.IdToken); } catch { AuthenticationResult result = await cca.AcquireTokenSilentAsync(oauth2appscopes.Split(' '), cca.Users.First()); // throw; } }
In the following task where the app gets the access token, SignInManager<ApplicationUser>.GetExternalLoginInfoAsync returns null (need to get the "ExternalLoginInfo", so that I can get the "userId" (user-defined) from it):
public async Task<string> GetAccessToken() { string accessToken = null; // Load the app config from web.config string appId = _oauth2.AppId; string appPassword = _oauth2.AppPassword; string redirectUri = _oauth2.RedirectUri; string[] appScopes = _oauth2.AppScopes .Replace(' ', ',').Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); ExternalLoginInfo info = await _signInManager.GetExternalLoginInfoAsync(/*userId*/); // ClaimsPrincipal principal = User as ClaimsPrincipal; // ClaimsIdentity principalIdentity = principal.Identity as ClaimsIdentity; string userId = info.Principal.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; // Get the current user's ID // string userId = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; // string userId = principalIdentity.FindFirst(ClaimTypes.NameIdentifier).Value; // string userId = principal.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; if (!string.IsNullOrEmpty(userId)) { // Get the user's token cache Microsoft.Identity.Client.TokenCache tokenCache = new SessionTokenCache(userId, HttpContext).GetMsalCacheInstance(); // Microsoft.Identity.Client.TokenCache tokenCache = new NaiveSessionCache(userId, HttpContext.Session); ConfidentialClientApplication cca = new ConfidentialClientApplication( appId, redirectUri, new Microsoft.Identity.Client.ClientCredential(appPassword), tokenCache, null); Microsoft.Identity.Client.AuthenticationResult result = await cca.AcquireTokenSilentAsync(appScopes, cca.Users.First()); if (result != null) { accessToken = result.AccessToken; } } return accessToken; }
After logging into an account with an external login, I tried accessing the inbox of the external login, but it is not working, ultimately because of SignInManager<ApplicationUser>.GetExternalLoginInfoAsync returning null. I do not know how I can get the "userId" (user-defined) another way.
It appears that the only times that SignInManager<ApplicationUser>.GetExternalLoginInfoAsync DOES NOT return null is in the following two functions, which are callback functions that execute after a user logs in via an external login provider:
// // GET: /Manage/LinkLoginCallback [HttpGet] public async Task<ActionResult> LinkLoginCallback() { try { var user = await GetCurrentUserAsync(); if (user == null) { return View("Error"); } var info = await _signInManager.GetExternalLoginInfoAsync(/*_userManager.GetUserId(User)*/); if (info.LoginProvider == "" || info.Principal.FindFirst("preferred_username").Value == "") { return RedirectToAction(nameof(ManageLogins), new { Message = ManageMessageId.EmptyError }); } var result = await _userManager.AddLoginAsync(user, info); var message = ManageMessageId.Error; if (result.Succeeded) { var code = await _userManager.GeneratePasswordResetTokenAsync(user); var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme); string emailSubjectToVisitor = "A(n) " + info.LoginProvider + " account (UserName: " + info.Principal.FindFirst("preferred_username").Value + ") has been added to your " +"globalwarming.center account (UserName: " + user.UserName + ")"; string emailMessageToVisitor = "<p>Dear " + user.UserName + ":</p><p>" +"A(n) " + info.LoginProvider + " account (UserName: " + info.Principal.FindFirst("preferred_username").Value + ") has been added to your " +"globalwarming.center account (UserName: " + user.UserName + ").</p><p>If you did " +"not add this account, someone else may have access to your globalwarming.center " +"account. You should immediately reset your password by clicking this " +$"<a href='{callbackUrl}'>link</a> and filling out the form. That way, you can " +"change your password and prevent anyone else from logging into your " +"account. Then, you should log into your account and remove the " + info.LoginProvider + " account, if necessary.</p><p>" +"Thank you." + "</p><p>" +"Sincerely," + "<br>" + _pointOfContact.FullName + "<br>" + _pointOfContact.Title + "</p>"; await _emailSender.SendEmailAsync(user.Email, emailSubjectToVisitor, emailMessageToVisitor); message = ManageMessageId.AddLoginSuccess; // Clear the existing external cookie to ensure a clean login process await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); return RedirectToAction(nameof(ManageLogins), new { Message = ManageMessageId.AddLoginSuccess }); } else { string error = result.Errors.First().Description; return RedirectToAction(nameof(ManageLogins), new { Message = message, Error = error }); } } catch (Exception ex) { return RedirectToAction(nameof(ManageLogins), new { Message = ManageMessageId.Error, Error = ex.Message }); } }
// // GET: /Account/ExternalLoginCallback [HttpGet] [AllowAnonymous] public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null) { if (remoteError != null) { ModelState.AddModelError(string.Empty, $"Error from external provider: {remoteError}"); return View(nameof(Login)); } ExternalLoginInfo info = await _signInManager.GetExternalLoginInfoAsync(/*_userManager.GetUserId(User)*/); if (info == null) { // return RedirectToAction(nameof(Login)); ModelState.AddModelError(string.Empty, "Could not get external login info"); return View(nameof(Login)); } // Sign in the user with this external login provider if the user already has a login. var result = await _signInManager.ExternalLoginSignInAsync( info.LoginProvider, info.ProviderKey, isPersistent: false); if (result.Succeeded) { _logger.LogInformation(5, "User logged in with {Name} provider.", info.LoginProvider); return RedirectToLocal(returnUrl); } /* if (result.RequiresTwoFactor) { return RedirectToAction(nameof(SendCode), new { ReturnUrl = returnUrl }); } */ if (result.IsLockedOut) { return View("Lockout"); } else { // If the user does not have an account, then ask the user to create an account. ViewData["ReturnUrl"] = returnUrl; ViewData["LoginProvider"] = info.LoginProvider; ClaimsIdentity principalIdentity = info.Principal.Identity as ClaimsIdentity; string preferredUsername = principalIdentity.FindFirst("preferred_username").Value; ViewData["PreferredUsername"] = preferredUsername; return View("ExternalLoginConfirmation", new ExternalLoginConfirmationViewModel { Email = preferredUsername }); } }
Here is the link to my GitHub repository.
Thank you.
Hello,
I am developing a WebSite in ASP.NET CORE MVC that uses Identity Framework for User Authentication. The WebSite heavily relies on User being logged in. In order, to improve user experience I am using AJAX calls for things such as populating some views etc....
The problem that I encounter is that if the ajax calls are making a calls to an action inside a controller that is decorated with an attribute [Authorize] I can get a 401 response while still being logged in on the website. To make matters worse the problem is inconsistent, meaning it can work or it can't . My take on it that it has something to do with cookies that identity framework is using.
I spend a week online looking for a solution and could not find anyone with the similar problem. Is it a bad idea to make ajax calls when using identity framework? should I have an independent authentication mechanism for ajax calls ? Or am I implementing something wrong in the initial solution. Thank you !
While Microsoft suggests to avoid using Hungarian notations in code, why do the system generated code of Event Handler contains following line?
private void TextBox1_TextChanged(object sender, EventArgs e)
Notice that "e" is in Hungarian notation.
Does this rule not apply to Event Handlers?
Using asp.net core 2.0 with Visual Studio Community 2017 for Mac
Created a brand new asp.net core web app project using the provided template
Click run project
Project builds successfully
Browser opens and shows message: Safari Cannot Open The Page - Safari cannot open the page localhost:5001 because the server unexpectedly dropped the connection
In Visual Studio Community IDE the Program.cs file loads with BuildWebHost(args).Run(); highlighted
Click continue button in IDE brings up a Program Report for dot net - dot net quit unexpectedly
Note that the asp.net core empty template runs without an issue
We are porting a MVC app to .NET Core 2.0 running in Service Fabric.
We have a problem in getting the Authentication information back in ApiControllers while in the Controllers it is just fine.
In the Controllers the IPrincipal user contains the following Claims:
((System.Security.Claims.ClaimsPrincipal) user).Claims.ToList()
Count = 10
[0]: {aio: Y2NgYMhnbwzUr/yYsOK0R1nEyvkyGeVFa+9uYZvo9cGe44rdRnMA}
[1]: {http://schemas.microsoft.com/claims/authnmethodsreferences: pwd}
[2]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname: Administrator}
[3]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname: MOD}
[4]: {name: MOD Administrator}
[5]: {http://schemas.microsoft.com/identity/claims/objectidentifier: 41dd586d-9b31-17f2-9772-2b52f258ae98}
[6]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier: BE_66VwY4Lei3rfK_nOeoguQ24ST6Ui5rlzWtI0cr3A}
[7]: {http://schemas.microsoft.com/identity/claims/tenantid: 62aca416-37f7-4357-8a0c-26fd874bb37b}
[8]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: admin@somesite.onmicrosoft.com}
[9]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn: admin@somesite.onmicrosoft.com}
The controller call returns a View that contains a devexpress dxtree, this contains a url to revive data for the tree, and this call is a call to an ApiController, when the call arrives at the APiController the IPrincipal user contains only those two claims:
[0]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: }
[1]: {http://schemas.microsoft.com/ws/2008/06/identity/claims/role: }
And we really need the other claims there. Obviously this was working flawlessly in the ASP.NET app. but not (yet) in the Core 2.0.
What are we missing the get this working?
Our code:
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IConfigurationRoot>(this.Configuration);
// Add MVC services to the services container.
services.AddMvc();
// Add Authentication services.
services
.AddAuthentication(sharedOptions =>
{
sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie(options => new CookieAuthenticationOptions
{
ExpireTimeSpan = TimeSpan.FromDays(14),
SlidingExpiration = false,
Cookie = new CookieBuilder
{
Name = "qtx"
}
})
.AddOpenIdConnect(option =>
{
option.ClientId = Configuration["AzureAd:ClientId"]; ;
option.ClientSecret = Configuration["AzureAd:ClientSecret"]; ;
option.Authority = $"{Configuration["AzureAd:AadInstance"]}/{Configuration["AzureAd:Tenant"]}";
option.SignedOutRedirectUri = Configuration["UrlsEtc:SignedOutRedirectUri"];
option.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
option.GetClaimsFromUserInfoEndpoint = false;
option.Scope.Add("openid");
option.SaveTokens = true;
option.ResponseType = "code id_token";
option.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
{
ValidateIssuer = false
};
option.Events = new OpenIdConnectEvents()
{
OnRemoteFailure = async context =>
{
context.HandleResponse();
context.Response.Redirect("/Home/Error?message=" + context.Failure.Message);
return;
},
OnRedirectToIdentityProvider = async context =>
{
var uri = context.Request.Path; //to do to get the return uri
context.ProtocolMessage.RedirectUri = Configuration["UrlsEtc:RedirectUri"];
context.ProtocolMessage.PostLogoutRedirectUri = Configuration["UrlsEtc:SignedOutRedirectUri"];
return;
},
OnTokenValidated = async context =>
{
return;
},
OnAuthenticationFailed = async context =>
{
return;
},
OnTokenResponseReceived = async context =>
{
return;
},
OnTicketReceived = async context =>
{
return;
},
OnUserInformationReceived = async context =>
{
return;
},
OnAuthorizationCodeReceived = async context =>
{
var request = context.HttpContext.Request;
var currentUri = UriHelper.BuildAbsolute(request.Scheme, request.Host, request.PathBase, request.Path);
var credential = new ClientCredential(context.Options.ClientId, context.Options.ClientSecret);
var distributedCache = context.HttpContext.RequestServices.GetRequiredService<IDistributedCache>();
string objectId = context.Principal.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
string tenantId = context.Principal.FindFirst("http://schemas.microsoft.com/identity/claims/tenantid").Value;
string signedInUserId = context.Principal.FindFirst(ClaimTypes.NameIdentifier).Value;
string signedInUserName = context.Principal.Identity.Name;
var adalTokenCache = new ADALTokenCache(signedInUserId, tenantId, objectId, signedInUserName, GetConnectionString(Configuration));
//AuthenticationContext authContext = new AuthenticationContext(ConfigSettings.idaAADInstance + tenantId, adalTokenCache);
AuthenticationContext authContext = new AuthenticationContext(context.Options.Authority, adalTokenCache);
var result = await authContext.AcquireTokenByAuthorizationCodeAsync(
context.ProtocolMessage.Code, new Uri(currentUri), credential, context.Options.Resource);
context.HandleCodeRedemption(result.AccessToken, result.IdToken);
//AuthenticationResult result2 = await authContext.AcquireTokenByAuthorizationCodeAsync(
// code, new Uri(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path)), credential, ConfigSettings.graphResourceID);
if (!_tenantService.TenantExists(Guid.Parse(tenantId)))
{
context.ProtocolMessage.RedirectUri = Configuration["UrlsEtc:RedirectSignupUri"];
}
return;
},
OnMessageReceived = async context =>
{
return;
},
OnRedirectToIdentityProviderForSignOut = async context =>
{
return;
},
OnRemoteSignOut = async context =>
{
return;
},
};
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseAuthentication();
// Add the console logger.
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
// Configure error handling middleware.
app.UseExceptionHandler("/Home/Error");
// Add static files to the request pipeline.
app.UseStaticFiles();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
// Configure MVC routes
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
routes.MapRoute(
name: "api",
template: "api/{controller}/{action?}");
});
}
Thanks
Ben
Hi All,
I'm currently working with C# on .net core 2 on:
- x86 windows,
- x86 linux,
- ARM linux
I would like to use raw socket in my C# solution.
On windows everything works fine, on linux (x86 and ARM) i get en error:
" Unhandled Exception: System.Net.Sockets.SocketException: Protocol not supported at System.Net.Sockets.Socket..ctor(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType) "
Some code that throws that exception:
mainSocket = new Socket(AddressFamily.InterNetwork,SocketType.Raw, ProtocolType.IP);
And my question is:
1st. - It this possible to get a raw socket using C# and .net 2 on any linux distribution?
2nd. - If not how to get a raw data from physical network interface under linux using C# ?
hi,
can any one please help me in finding the ways to start capturing video from application using mvc core 1.0 c#
thanks,
priya
hi,
I created a View Component named "LoginForm".
When I use @await Component.InvokeAsync("LoginForm"), it works. But tag helper <cv:login-form></vc:login-form> shows nothing.
I added @addTagHelper *, Web.ViewComponents in _ViewImports.cshtml
My app is asp.net core 2.0 and using sdk 2.0.2.
What did I miss? Thanks.
namespace Web.ViewComponents { /// <summary> /// Login Form Component /// </summary> [ViewComponent(Name = "LoginForm")] public class LoginFormViewComponent : ViewComponent { public async Task<IViewComponentResult> InvokeAsync() { return View(); } } }
Hi,
I would like to know if it is possible to run Websocket and WebAPI functionality in one ASPNet Core 2.0 app. If so, is there a sample implementation? Thank you.