|
Thanks
That does put a damper on things. This would have opened up all sorts of nice excel options, but now i must illustrate the pie graph in the view for the user...Thanks!
|
|
|
|
|
Take a look at NPOI
"We can't stop here - this is bat country" - Hunter S Thompson - RIP
|
|
|
|
|
I have a Security API which creates a JWT token and works well with SPA front ends that we create with no issue.
Now I have been asked can I get this working with a MVC app that was built in MVC4 and Dot Net 4.5.1
does anyone have any links to tutorials or examples that I can see if it is possible?
Thanks
Simon
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Sounds like you need to investigate each issue one at a time and test it.
Like how to write the JWT token to local storage, or the view bag or something.
Then how to get the controller to expect the JWT token [Authorize]
And how to send the token to the controller in the HTTP header. Do some reverse engineering.
I looked around on the interwebs and just basically saw nothing of value.
Just a bunch of forum post saying look at this by people who have never worked with JWT.
most talk were for core.
Sounds like a big job to me just to investigate it.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
you are right and that is why I posted here to see if someone has done it.
I have a legacy system that is written in dot net 4 and MVC4
were currently trying to strangle it as it is used by the whole company. With the new stuff we are using JWT and have a single sign on API which works and works well. BUT the MD wants to me see if it is possible
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
I think it's possible to do personally, although I haven't done it nor put any day long research into it. Or perhaps at least just start with a piece of JWT, such as picking up the token from the other modern project to background validate in the old MVC4 system so you don't have to sign in again, and then the old system just runs as normal. That is very plausible to do. It's even plausible to me at least, to modify the old system so when you sign in, it writes a JWT token to local storage as well so you don't don't have to sign in to the new system.
JWT tokens stored in local storage have to use the client to read and write them, and I did see some source code concepts to get a view page to store the token in a hidden textbox, and then use Vanilla JavaScript to read that textbox and write it to Local storage. Or the other way around, use Vanilla JavaScript to read that token in Local Storage and write it to a hidden textbox. Then when the view page post back, the token will post as well and can be retrieved.
I pretty sure I can write a hack of AttributeUsageAttribute and call it [Authorize] that I can decorate the controller ActionResult with that will validate a token. Basically a hack of System.Identity but in a smaller package. Store the token in a cookie and can read and write it.
On SPA apps, well Angular at least, you don't have to store the token in Local Storage, but it can be stored in a cookie as well. But the cookie has to be a real single value cookie, and not the asp.net cookie that can store an array of values.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
It can be done, a teammate of mine migrated an old WebForms app to use it
Director of Transmogrification Services
Shinobi of Query Language
Master of Yoda Conditional
|
|
|
|
|
I need to get data from a web service described as:
curl --header 'Authorization: Bearer fxTWi96Uxe97gsstB3kh99VNKRuuaW3s_1615442626' -X GET 'https://api.muztorg.ru/xvendor'
When calling a function:
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer SR-OM5Bvb8Fh61S4jaRUktaOs8D5rv5C_1618658296");
client.DefaultRequestHeaders.Add("ContentType", @"application/json-rpc;charset=utf-8");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", @"SR-OM5Bvb8Fh61S4jaRUktaOs8D5rv5C_1618658296");
HttpResponseMessage response = await client.GetAsync(@"https://api.muztorg.ru/xvendor");
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
I get a 502 error.
When I make a call from Fiddler, I get the same error.
But a call from Insomnia is successful.
|
|
|
|
|
I'm implementing asp.net core project. I published my project into a package and set it on a main server, but, the database was set on another server. To do that, in the part of connection string of appsetting file, I just changed the server name and database name and when running the project I confront with the following error:
َError.
An error occurred while processing your request.
Request ID: |6baffbe3-48f1cf1e3a28ac47.
Development Mode
Swapping to Development environment will display more detailed information about the error that occurred.
The Development environment shouldn't be enabled for deployed applications. It can result in displaying sensitive information from exceptions to end users. For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development and restarting the app
I appreciate if anyone can suggest me a solution for it.
|
|
|
|
|
You are assuming a database connection error, the production system has hit an error but will not tell you about it because of security concerns - it could be any error, not necessarily the DB connection. You need to get more information about the error either from the logs or turn on development mode.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Part of learning .Net Core requires you to take a deep dive into how to setup the environment using the Program.cs and Startup.cs, and how to use environment variables. For my database setup, I ran a database on my workstation to develop on, and one on the production server, and used the appSettings file to switch between production and development. If you can contact the database server from your workstation, then all is good.
So using the development mode to run off the production database server would be a good way to figure out what's happening. Then maybe take a step back and setup your environment.
appSettings.Development.json
appSettings.Production.json
and load the correct one in Programs.cs, this is just a sample of what you can do within the environment.
bool.TryParse(Environment.GetEnvironmentVariable("ASPNETCORE_OPTIMIZE"), out var optimize);
bool.TryParse(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER"), out var isDocker);
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hostSettings.json", optional: true, reloadOnChange: true)
.AddJsonFile("secrets.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appSettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: false, reloadOnChange: true)
.AddJsonFile($"certificate.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: false, reloadOnChange: true)
.Build();
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
LS,
I need to display one image that is made up of multiple images with each a transparency.
So image one has a bike on the left and the rest of the image is transparent and the second image has a car on the right (again the rest is transparent), then I would need to display one image with a bike on the left and a car on the right.
How can I accomplish this in MVC Core 3.1?
As the user can select the images that build the total image I cannot prebuild this image.
Kind regards,
Clemens Linders
|
|
|
|
|
You could use either CSS or SVG to stack the images on top of each other.
If you want to generate a single image on the server then you'll need to use a graphics library which is compatible with .NET Core to do it. For example:
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Richard,
Just how would I do this in CSS or SVG?
Kind regards,
Clemens Linders
|
|
|
|
|
Assuming you want the images to be centred within their containing block, try something like this:
<div class="image-stack">
<img src="..." />
<img src="..." />
...
</div>
.image-stack {
position: relative;
width: 500px;
height: 500px;
}
.image-stack img {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
} In this case, the images need to be listed in order from bottom to top; each subsequent image will appear on top of the previous image.
Another option would be to use multiple background images:
<div class="image-stack"></div>
.image-stack {
width: 500px;
height: 500px;
background-image: url('...'), url('...'), ...;
} NB: In this case, the images need to be listed in order from top to bottom.
Using multiple backgrounds - CSS: Cascading Style Sheets | MDN[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Richard,
Thanks for your effort. I currently have no development PC at my disposal. But it looks very easy and logical.
I will give this a try asap and I expect no troubles.
Kind regards,
Clemens Linders
|
|
|
|
|
I'm implementing an asp.net core project and I'm trying to authenticate the user login via ldap to active directory. I'm using the below link https://www.brechtbaekelandt.net/blog/post/authenticating-against-active-directory-with-aspnet-core-2-and-managing-users in order to implement the authentication against active directory with asp.net core. What I've tried in appsettings is like below:
{
"AllowedHosts": "*",
"ConnectionStrings": {
"CSDDashboardContext": "Server=xxxx;Database=CSS;Trusted_Connection=True;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"LdapSettings": {
"ServerName": "par.fr",
"ServerPort": 389,
"UseSSL": false,
"Credentials": {
"DomainUserName": "par\\koli-h",
"Password": "asdq/1998"
},
"SearchBase": "CN=Users,DC=par,DC=fr",
"ContainerName": "CN=Users,DC=par,DC=fr",
"DomainName": "par.fr",
"DomainDistinguishedName": "DC=par,DC=fr",
"SearchProperty": "samAccountName" //????
}
}
Now my problem is after running the project and entering the user: koli-h and pass: asdq/1998 the system shows me invalid username or password. My real username and password in the server are koli-h and asdq/1998. However, if I change my user in the code to for example koli-ha (adding a character in order to make the usernam incorrect) after running the project, the system shows me "Invalid Credentials" error. I appreciate if anyone could suggest me what is the problem that I can't logging in to the system.
|
|
|
|
|
I have no answer for you.
But can say like the article said, .Net Core is designed to run in many environments including Linux, Mac OS, and has no idea or really doesn't care what the environment is. With that being said, I really think using Active Directory to store credentials is a bad idea in the first place. You can fix and figure it out now, but the problem will come up again when you deploy it in a production environment.
Issues like this, is really dependent upon you setting up your development environment exactly like your production environment, so when you write code, it works. I develop on a Win10 computer, but I run my program on a Linux server running in a Docker Container. I had to write code to detect a Linux environment and make adjustments to it such as file names. Plus had to write code to detect that I'm running in a Docker Container as well.
The AppSettings file is a place to store parameters. So your logging level is just a parameter. Then you have to write code to detect the error, pickup the logging parameters, and then write code to log the error in the Windows Server logging system. But for this to work, you have to be running in Windows Server. I suggest focusing on the authentication first, and find another way to capture the error so you can examine it.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
We are using a group of third party webservice dlls in our apps.
I have been trying to develop a .Net Core version of an app, but as soon as it hits the non-core dll, it throws an error loading one of it's dependencies.
Quote: System.BadImageFormatException: 'Could not load file or assembly 'System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (0x80131058)'
I have no control of the webservice source, so I can't develop a core library.
With all the push for Core, I find it hard to believe nobody has found a fix for this. There are a ton of third party libraries out there.
|
|
|
|
|
|
I had to dump all that stuff from System.Web.Services and rewrite new ones in the Core format. Frustrating at first but now easy to understand how Core works now. No regrets, my new stuff is better and faster.
But I've manage to find a qualified NuGet package to replace some items like System.Drawing.Common, just took time for research and testing to qualify them which was time consuming. And I found better solutions in other packages.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Good evening everyone!!!
Sorry, I don't know the right keywords to search neither do I have idea on how to go about this.
Please, I designed a blogging site and everything is working fine when only text is been posted.
Now, I want to add the functionality where someone can post both text and image.
For instance,
Making a table
Step 1: Gather your woods and arrange as depicted with the following image
Image goes here>>>>>
Step 2: Get the following tools as shown below
Image goes here>>>>>
Now, when I submit this post I want both image and text to be saved to database.
And when I view this post, I want to see post text and images just as instructable.com does.
What I have tried
I tried saving text and using inline scripting as follows but didn't work
Step 1: blabla
Image path
<br />
<img src="image path" style="image"/><br />
But when I view this post, image never display...
But I discovered that when I copied the image url, is showing the routed URL.
So what is the best way to this please...
Any ideas and guide will be welcome
|
|
|
|
|
I have finally gotten the solution. Let me add this should in case anyone else needs it.
The trick was to set the image src to the site domain name, the image folder, and the extension
<img src="https://www.sitedomainname/folderimage/imagename.ext" width="100px" height="100px"/><br />
That's it
|
|
|
|
|
Hellow my dears.
i use asp.net core and identity authorization in this.
my side menu is static and I want to create menu and sub menu.my problem is when i hide sub menus of a menu,menu show to user but i want it Do not display.can i use jaquery function to this?
my code is here:
<li class="kt-menu__item kt-menu__item--submenu"onload="hide()" aria-haspopup="true" data-ktmenu-submenu-toggle="hover" style="@cursercartable;@curserchangepass">
<a href="javascript:;" class="kt-menu__link kt-menu__toggle" a style="@LockCartabl;@LockChangepass" >
class="kt-menu__link-icon fas fa-plane"__^
</a>
<div class="kt-menu__submenu SubbMenu " style="display: none; overflow: hidden;" kt-hidden-height="130" >
<ul class="kt-menu__subnav ">
<security-trimming asp-area="Admin" asp-controller="Missions" asp-action="Create">
<li style="@cursercartable;@curserchangepass" class="kt-menu__item " aria-haspopup="true"><a style="@LockCartabl;@LockChangepass" asp-action="Create" asp-controller="Missions" asp-area="Admin" class="kt-menu__link ">^__i class="kt-menu__link-icon fas fa-plane">درخواست ماموریت</a></li>
</security-trimming>
<security-trimming asp-area="Admin" asp-controller="Missions" asp-action="Index">
<li style="@cursercartable;@curserchangepass" class="kt-menu__item " aria-haspopup="true"><a style="@LockCartabl;@LockChangepass" asp-action="Index" asp-controller="Missions" asp-area="Admin" class="kt-menu__link ">^__i class="kt-menu__link-icon fas fa-plane">ماموریت</a></li>
</security-trimming>
<security-trimming asp-area="Admin" asp-controller="Missions" asp-action="Reportmission">
<li style="@cursercartable;@curserchangepass" class="kt-menu__item " aria-haspopup="true"><a style="@LockCartabl;@LockChangepass" asp-action="Reportmission" asp-controller="Missions" asp-area="Admin" class="kt-menu__link ">^__i class="kt-menu__link-icon fas fa-bed"> گزارش ماموریت</a></li>
</security-trimming>
</ul>
</div>
</li>
|
|
|
|
|
Great article. Very informative. Thank you
|
|
|
|
|