|
Hi, thanks for replying. I don't know if you understood my questions above but let me rephrase. What I'm asking is if my web project consists of only HTML files, some Javascript files, a Web API, and nothing else. Would it be possible to provide security to my web project?
Remember that I did not mention MVC or Web Form. If it is possible to secure my project without using MVC controllers or web form, how would I authorize users after successful logins?
modified 1-May-20 8:46am.
|
|
|
|
|
MadDashCoder wrote: I did not mention MVC or Web Form True, but the issue is much the same: we api authorization[^]
|
|
|
|
|
Is it possible to generate an MVC project folder and files using Web API 2.2? I'd like to know because I need to generate MVC project folder and files dynamically.
|
|
|
|
|
You can do it with Visual Studio.
|
|
|
|
|
I guess my question is not very clear. What I meant is can a web project folder and web files (.cshtml, web.config, etc.) be generated using functions we write in a Web API after the Web API project has been built and deployed to the server.
Basically the question is, can we send a call to the Web API functions at run time to create a web project folder and web files dynamically (meaning this happens after building and deploying our Web API project to the server).
modified 1-May-20 8:48am.
|
|
|
|
|
Well, assuming you have the skills to create all the files then I would guess it is possible.
BTW, why are you using two accounts here? You should close one of them.
|
|
|
|
|
You can generate the files on the server and pass them to the client but if the client is a browser then it will be a download as it cannot write to the local disk.
Otherwise you are going to have to write a client to write the file to disk.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Hey chaps
Young programmer here.
Does anyone know how to produce an excel pie graph in excel through MVC C+, Jquery or even SQL? I have the pie graph with rows 1 to 10 and would like to produce a pie excel graph with data in it when the excel is downloaded through a website.Any links would be appreciated, many thanks and remember to sneeze into your elbow!!
|
|
|
|
|
As far as I know the graph details need to be embedded in the Excel worksheet. I guess it may be possible if you know the worksheet layout to add the details through the use of the ACE Excel driver. But I am not 100% sure that that is what you are asking.
|
|
|
|
|
Thanks
Not quite, but I guess close. Someone is going to be drawing a report from a website. Inside the excel spreadsheet is various data. I want this data (when opened in excel) to also have a pie graph attributed to it. Thanks!
|
|
|
|
|
If you're thinking about automating Excel from your ASP.NET MVC application, you should read the following Microsoft knowledgebase article:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
The same would apply to automating it from SQL.
Javascript will not be able to automate it at all. Even if the user had Excel installed, Javascript is not allowed to access or automate applications on the user's computer for security reasons.
To generate an Excel file on the server, you would need to use a library which doesn't rely on automating Excel. For example:
The OpenXML SDK[^]
How to: Insert a chart into a spreadsheet document (Open XML SDK) | Microsoft Docs[^]
(Previously I would have recommended EPPlus, which supports charts. But unfortunately, it's no longer free. The other go-to library, ClosedXML[^], doesn't support charts yet.)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
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
|
|
|
|