|
Bonjour,
Je débute le développement et l’utilisation des web services.
Ce web service sera développé dans un environnement ASP.NET et doit permettre d'accéder à une base des données oracle 11g distante pour récupérer des données de certaines tables.
Après sera appelé et utilisé dans une application web mcv développée sous visuel studio 2012.
Comment faire afin de développer et utiliser ce web service ?
Merci.
|
|
|
|
|
Hello I am working on a project where I must be able to display information recorded via a form in a datatable without going through the registration of the database, I suppose that it will be to record the information in a list to browse it and display the information in the datatable. but I really don't know how to do it. and is it already possible?
|
|
|
|
|
You have already posted this in QA:
Insert data into list from form[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
In our web app, as expected, the DbContext for our data is injected with DI.
It is registered with this extension method (the one that take a Func<> factory method):
public static IServiceCollection AddScoped<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory) where TService : class;
Now every now and then, due to maintenance task in our UAT servers, the Database is offline for a little while.
If that ever happen while someone try to connect to the DB, anyservice that need that DbContext fail with the same exception. Regardless whether the DB is back online or not.
We need to restart the app to fix that.
Now I wonder.. is there a way to fix that? (A way that doesn't involve restarting our app!)
[EDIT] Solved
It was DI for Startup.Configure() which prevented the application from running.
DI itself is fine and as expected!
modified 12-May-20 1:20am.
|
|
|
|
|
That doesn't sound right. Each request should result in a new instance of the DbContext , which should make a new connection. The failure of a previous connection shouldn't affect it.
What does the implementation factory look like, and what's the exception?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
my bad....
it was DI for Startup.Configure() which was bringing the application down....
so DI is fine, it's just the app was broken!
|
|
|
|
|
Hi all, how do I set a route ( or attribute or whatever ) so I can call this method which is present in a net core api controller ? assume my controller is called MyController - I've googled endlessly and can't find a simple answer
I would like to be able to access it something like this
myipaddress:myportnumber/MyController/1
public ActionResult<Actuator> GetAValue(int id)
{
return businessLayer.GetAValue(id);
}
"We can't stop here - this is bat country" - Hunter S Thompson - RIP
|
|
|
|
|
There's an example on the Microsoft docs site which is close to what you want:
Routing to controller actions in ASP.NET Core | Microsoft Docs[^]
[Route("[controller]")]
[ApiController]
public class MyController : ControllerBase
{
[HttpGet("{id:int}")]
public ActionResult<Actuator> GetAValue(int id)
{
...
}
}
"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 the suggestion but I'm still getting a 404 - v weird
Edit
Apologies Richard it does work - thanks again
"We can't stop here - this is bat country" - Hunter S Thompson - RIP
modified 6-May-20 5:37am.
|
|
|
|
|
I use this for API JSON Calls. But you can tweak into other uses as well
[Produces("application/json")]
[Route("api/[controller]")]
[ApiController]
public class MyController : ControllerBase
{
[HttpGet("GetWarehousesKv/{vendorId}")]
public async Task<List<KeyValue>> GetWarehousesKv(string vendorId)
{
return await myRepository.GetWarehousesKv(vendorId);<br />
}
}
And I call it like this.
Notice the controller route prefix api ?
and notice the controller name My
https://domain.com/api/my/GetWarehousesKV/500689
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hi thanks for that I have it sorted now
"We can't stop here - this is bat country" - Hunter S Thompson - RIP
|
|
|
|
|
Cool!
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Suppose I have a web project that is made up of a Web API, a bunch of HTML files, and some Javascript files. Is it possible to provide security to my project files with nothing more than a login page which posts a user's credentials to the Web API which then queries the database to check if the user exists?
If it's possible, how would I control things like redirect users to a certain page upon successful login or better yet prevent users from accessing any page other than the login page if they're not logged in?
modified 1-May-20 2:59am.
|
|
|
|
|
|
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
|
|
|
|