|
|
I'm creating a app that will have WPF, Web, and Android clients.
My first task is to create a Web API. I want to implement a login method. I already have the Security class done. What I need to do is expose a Login method.
So, I created this:
public class LoginController : ApiController
{
public UserEntity Login(string userName, string password)
{
UserEntity results = null;
var credentials = new CredentialEntity();
credentials.UserName = userName;
credentials.Password = password;
var connString = "";
var appSec = new ApplicationSecurity(connString);
appSec.Login(credentials);
if (appSec.IsUserLoggedIn)
{
results = appSec.CurrentUser;
}
return results;
}
}
1) is this the right way to expose this?
2) How do you test this in the browser? What would the URL look like?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I'd be inclined to make it a POST request, so that the credentials aren't exposed in the URL. (Although hopefully you're using SSL, which reduces that risk.)
Something like this:
[HttpPost]
[AllowAnonymous]
public UserEntity Login([FromBody] CredentialEntity credentials)
{
var connString = "";
var appSec = new ApplicationSecurity(connString);
appSec.Login(credentials);
return appSec.IsUserLoggedIn ? appSec.CurrentUser : null;
}
To test it in the browser, you'd need a form with the method set to POST and the action set to api/Login/Login . Alternatively, you could use a proper REST tool like Postman or Insomnia, which will give you more control over the request.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
OK,l Most of that went right over my head.
Do you know of any entry level Web API tutorials/books I can check out?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
The Microsoft docs site has some information:
Get Started with ASP.NET Web API 2 (C#) | Microsoft Docs[^]
There's also some details on the main ASP.NET site:
ASP.NET Web API | The ASP.NET Site[^]
For the most part, "it just works". The built-in media formatters and model binders know how to convert JSON, XML, and HTML <form> data to the method parameters, and how to convert the returned object back to the requested format. 95% of the time, you don' even need to know what a "media formatter" or "model binder" is.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Suppose I have a jqgrid and its code is as below
$("#jqGrid").jqGrid({
url: "/Folder/ShowProductsDetails",
editurl: '/Folder/EditProductDetails',
datatype: 'json',
mtype: 'Get',
ajaxSelectOptions: { type: 'POST' },
viewrecords: true,
prmNames: { id: "ProductsLineId" },
sortname: "Purchase_Date",
sortorder: "DESC",
hoverrows: true
},
colNames: ['ProductsLineId', 'Purchase Date', 'Company'],
colModel: [
{ key: true, hidden: true, name: 'ProductsLineId', index: 'ProductsLineId'},
{ name: 'Purchase_Date', title: false, stype: 'text', index: 'Purchase_Date', formatter: 'date',
formatoptions: { newformat: 'm/d/Y' }, editable: true, formoptions: { rowpos: 1, colpos: 2,
label: 'Purchase Date *' }, editrules: { required: true },
},
{ name: 'Company', title: false, stype: 'text', index: 'Company', formatter: 'date',
formatoptions: { newformat: 'm/d/Y' }, editable: true, formoptions: { rowpos: 1, colpos: 2,
label: 'Purchase Date *' }, editrules: { required: true },
}
],
shrinkToFit: false,
pager: jQuery('#jqControls'),
rowNum: 50,
rowList: [50, 100, 150, 200],
scrollerbar: true,
height: 'auto',
autoheight: true,
autowidth: true,
viewrecords: true,
caption: 'Uploaded Product Details',
emptyrecords: 'No Records are Available to Display',
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
id: 'ClaimsLineId'
},
multiselect: true
}).navGrid('#jqControls', { add: false, edit: true, del: true, search: true, refresh: true},
{//Code for Add},{//Code for Edit},{//Code for Delete}
How do I pass data from jqgrid using editurl to the server-side MVC controller method ShowProductsDetails whose signature is
public ActionResult ShowProductsDetails(string operation Product prod, string extraData)
- operation is operation that user can choose like del for delete.
- prod is product which contains Product data from jqGrid.
- extraData is data passed as extra data using editData.
The value of operation is used to determine whether to perform Edit, Delete, or Save
modified 16-Jun-18 8:00am.
|
|
|
|
|
Hello there, i am web developer and i wanted to know how to make user list
any questions on tutorial?
also please reply.
|
|
|
|
|
I don't understand your question.
Does user list mean a list of users who will be accessing your application? Something to due with building security into your application.
Please provide more information ...
|
|
|
|
|
Is there a section here for CSS? I got a CSS question....
|
|
|
|
|
You actually can post css, css is web development thing too
|
|
|
|
|
Hi all,
I am trying to get multiple rows data which has same id. So the same id can be allocated to different entries and I need to display this.
The code as follows:
<pre><?php require_once('Connections/eam.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_rsMaintenanceAsset = "-1";
if (isset($_GET['recordID'])) {
$colname_rsMaintenanceAsset = $_GET['recordID'];
}
mysql_select_db($database_eam, $eam);
$query_rsMaintenanceAsset = sprintf("SELECT * FROM maintenance_history WHERE maint_id = %s", GetSQLValueString($colname_rsMaintenanceAsset, "int"));
$rsMaintenanceAsset = mysql_query($query_rsMaintenanceAsset, $eam) or die(mysql_error());
$row_rsMaintenanceAsset = mysql_fetch_assoc($rsMaintenanceAsset);
$totalRows_rsMaintenanceAsset = mysql_num_rows($rsMaintenanceAsset);
}
$pageTitle="Maintenance History"; ?>
<?php include('includes/header.php'); ?>
<h3>Maintenance history for Asset ID: <?php echo $colname_rsMaintenanceAsset; ?></h3>
<table class="table1">
<tr>
<th>Maintenance ID</th>
<th>Date Completed</th>
<th>By</th>
<th>Checklist</th>
<th>Comments</th>
<th>SPARE</th>
<th>View </th>
</tr>
<?php do { ?>
<tr onmouseover="this.bgColor='#F2F7FF'" onmouseout="this.bgColor='#FFFFFF'";>
<td> <?php echo $row_rsMaintenanceAsset['id']; ?> </td>
<td> <?php echo $row_rsMaintenanceAsset['date_completed']; ?> </td>
<td> <?php echo $row_rsMaintenanceAsset['by_staff']; ?> </td>
<td> <?php echo $row_rsMaintenanceAsset['maint_checklist']; ?> </td>
<td> <?php echo $row_rsMaintenanceAsset['maint_comm']; ?> </td>
<td> <?php echo $row_rsMaintenanceAsset['status']; ?> </td>
<td> <a href="HardwareDetail.php?recordID=<?php echo $row_rsMaintenanceAssets['maint_id']; ?>">View</a></td>
</tr>
<?php } while ($row_rsMaintenanceAssets = mysql_fetch_assoc($rsMaintenanceAssets)); ?>
</table>
Any help appreciated
|
|
|
|
|
And what is not working as expected?
Are there compilation or runtime errors?
Did you get any result or nothing?
Please note that we do not have access to your database or know about other code involved.
What you can do is inserting statements to print out intermediate results like the number of rows returned and the created SQL query string. The latter can be for example used with your database administration tool to check which results are returned. Are there any for the maint_id -1?
You should also check if SQL functions fail and report errors. This helps you to fix syntax errors in the query string.
|
|
|
|
|
Thanks for your reply. I have already sorted this issue. Problem was a spelling mistake in the while statement.
|
|
|
|
|
I read a lot of it and also tried some examples. On a first glance it is a very great Thing. My question: What does it means related to resources?
I mean e.g.: CP has about 13.5 Mio. members. Let assume 1 Mio. are online...
Is it realistic to use SignalR in such a Scenario?
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
I have recently moved my store over to Magento 2. The store is up and running and all is good. I've just noticed that for most products, Magento 2 has created 3 different URL's for the same product.
I'm try this(https://www.mageplaza.com/kb/how-to-configure-url-rewrite-magento-2.html)
But,I cannot get Magento 2 to renew URL rewrites for categories. I was forced to clear url_rewrites table after some weird problems happened after importing categories and products.
Now I get something like catalog/category/view/s/regntoj/id/304/.
|
|
|
|
|
How to merge two powerpoint presentation slides into one ppt using php or javascript ?
|
|
|
|
|
Hi Everyone,
Greetings!
1. Is there any way to create my own web application using MVC to do a video chat with my screen sharing?
2. If Yes, what are the required item before proceed.
Thanks in Advance,
Regards,
Gunasekaran P
|
|
|
|
|
This is for Google Apps Script and I need to know if it is a working translator go to the link
<a href=""></a><a href="https://script.google.com/d/1LUO84mMPGajslP-qfBcDSKXukx0DHkNiplOGjEvHpJXw7N9OOQwTfchB/edit?usp=sharing">Meet Google Drive – One place for all your files</a>[<a href="https://script.google.com/d/1LUO84mMPGajslP-qfBcDSKXukx0DHkNiplOGjEvHpJXw7N9OOQwTfchB/edit?usp=sharing" target="_blank" title="New Window">^</a>]
|
|
|
|
|
What happens when you try it?
|
|
|
|
|
ny python web developer here..who can help me.
|
|
|
|
|
You are looking for a fairly rare breed, then.
Ask your questions. I'm sure someone can help, or at least get you pointed in the right direction.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Suggest me some best free themes in wordpress for blog having grid layout.
|
|
|
|
|
It would be quicker for you to go to the Wordpress website and look at the examples for yourself.
|
|
|
|
|
|
hello again...
Attempting to design a site for my local area of NA [from scratch...(now in Pinegrow)...one that had previously been designed in Macromedia DW 2004...whereby all the child divs were of 'absolute' positioning; & resided inside a parent div set to margin: 0 auto...so everything was centered on the page (over a background image)]...but absolute positioning is horrible for responsive code construction; & I want our new site to be up to protocol for browser resize & smaller devices.
So...given the conspicuous lack of templates around the web (& in the app) that actually look like what I want to do...I worked up a rough sample of what the site should look like...roughly...(it's very simple, so this should be easy, right?):
http://www.moonjams.net/BurlCoNA.png
Keep in mind that all that you see above is always centered on the page (w/ a background image behind it)...& the page has to be responsive, whereby everything is distributed/flows correctly for browser resize & smaller devices.
ALSO: 1) The oval image block must be positioned where you see it on the page...top/left (in the parent)....over the gray rectangle.
ALSO 2) Speaking of which...the first child block (gray rectangle) is just that...a rectangular element filled w/ gray...not a header or paragraph or anything.
ALSO 3) Please don't send me to such-and-such tutorial or such-and-such code learning online seminar...I just want to do this on my own, so as to learn the basics of coding a responsive site along the way...(& if it turns out I'm too stupid for this task...if someone could put together a starter code page, where I could then place my own blocks/images/text...I would be happy to pay you, in kind...I just need to get this done; & my local area is waiting).
thanx,
dox
|
|
|
|
|