|
The Unchase OData client (UOC) creates the connection between the client (WebForm) and the OData service (over IIS). In IIS OData controllers send the data over the HTTPGet when requested. The UOC uses linq to translate the linq query to OData HTTP request.
The Reference.cs created by the UOC shows even the connections between tables in the DB over ODATA. What I now suspect is that the controller in the IIS does:
return db.Users.Where(x => !x.IsDeleted)
It is not using Include("UserGroups") to fill these nodes with data.
The linq query translates to requerst Uri:
http://localhost/api/global/Users?$orderby=Id
In Word you can only store 2 bytes. That is why I use Writer.
modified 4-May-22 4:23am.
|
|
|
|
|
I am getting the error below
Microsoft VBScript compilation error '800a0408'
Invalid character
/AspClassic/mail.asp, line 24
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = teckchandanirp@gmail.com
my code is as below, what am I doing wrong
<%@LANGUAGE="VBSCRIPT"%>
<%
'Step 1: create an object of CDO.Message
dim objMail
Set objMail = Server.CreateObject("CDO.Message")
'Step 2: set the smtp server, user name and password for authentication
dim smtpServer, yourEmail, yourPassword
smtpServer = "smtp.gmail.com"
yourEmail = "teckchandanirp@gmail.com" 'replace with a valid gmail account
yourPassword = "32233223" 'replace with a valid password for the gmail account set in yourEmail
'Step 4: set the email address to which email will be sent
sendEmailTo = "teckchandanirp@gmail.com"
'Step 5: set the configuration properties of objMail object
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtp.gmail.com
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = teckchandanirp@gmail.com
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = 32233223
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
'Step 6: update the configuration after setting all the required items
objMail.Configuration.Fields.Update
'Step 7: prepare your email like set subject, body, from, to etc.
objMail.From = teckchandanirp@gmail.com
objMail.To = teckchandanirp@gmail.com
objMail.Subject="Application Form Registration Details"
objMail.htmlBody = "This is test message"
'Step 8: send the email
objMail.Send
|
|
|
|
|
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = teckchandanirp@gmail.com
You need to put double quote characters around string constants, thus:
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "teckchandanirp@gmail.com"
|
|
|
|
|
I am building an app using MVC 5 and I ran into a common issue that has been asked over and over but I can't seem to find the right answer using .NET Identity. Once the user logs in, they should not be able to go back to the login page and the same is true when they log out they should not be able to go back to a restricted page.
The problem that I'm having is that if a user does not enter the correct password and the server catches the error then I successfully login I am able to go back to the login page. If I login on the first try it works like it should. How can I correct this problem?
The other problem that I'm having is when the user logs out, Is there any way without using javascript to not allow the user to access the restricted pages by using the back button?
I have included
filters.Add(new System.Web.Mvc.AuthorizeAttribute());
My controller looks like this:
[AllowAnonymous]
[OutputCache(NoStore = true, Location = OutputCacheLocation.None)]
public ActionResult Login(string returnUrl)
{
if (User.Identity.IsAuthenticated)
{
return RedirectToAction("Dashboard", "App");
}
ViewBag.ReturnUrl = returnUrl;
return View();
}
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
if (!ModelState.IsValid)
{
return View(model);
}
var user = await UserManager.FindByNameAsync(model.Email);
if (user != null)
{
if (!await UserManager.IsEmailConfirmedAsync(user.Id))
{
string callbackUrl = await SendEmailConfirmationTokenAsync(user.Id, "Confirm your account-Resend");
ViewBag.errorMessage = "You must have a confirmed email to log on.";
return View("Error");
}
}
var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
switch (result)
{
case SignInStatus.Success:
return RedirectToAction("Dashboard","App");
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.RequiresVerification:
return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
case SignInStatus.Failure:
default:
ModelState.AddModelError("", "Invalid login attempt.");
return View(model);
}
}
My Logout Controller is:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
return RedirectToAction("Index", "Home");
}
I didn't add anything special to my view. How do I prevent the logged in user from going back to the login page which they can do if they have an error. and how can I prevent the user from going back after logout and seeing a restricted page. What I really want to know is if there is any way to do this with Identity?
I know the issue is caching in the browser that allows the user to go back. I've cleared the cache when I logout, I used the
[OutputCache(NoStore = true, Location = OutputCacheLocation.None)]
I do not want to disable cashing for the whole app (performance issues) and I do not want to use javascript (since it can be disabled by the user). Is there any other way to do it?
I know this question has been asked a million times but I haven't really found a definitive answer that works on all browsers.
|
|
|
|
|
If you don't want the user to be able to load a cached version of a restricted page after logging out, then you have to disable caching for all restricted pages.
You cannot change the caching option for a previously-visited page after the page has already been visited.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
What does
CreatedAtAction(...) method do in the following code (a part of an API code)?
[HttpPost]
[Route("id:guid")]
public async Task<IActionResult> AddCard([FromBody] Card card)
{
card.Id = Guid.NewGuid();
await context.AddAsync(card);
await context.SaveChangesAsync();
return CreatedAtAction(nameof(GetCard), card.Id, card);
}
|
|
|
|
|
|
Hi,
What does [Route("id:guid")] mean in the following code? (This code is a part of an API)
[HttpGet]
[Route("id:guid")]
[ActionName("GetCard")]
public async Task<IActionResult> GetCard([FromRoute]Guid id)
{
var card = await context.Cards.FirstOrDefaultAsync(x => x.Id == id);
if(card != null)
{
return Ok(card);
}
return NotFound("Card not found");
}
|
|
|
|
|
|
|
Hello group, a question please. The data from my databases all come out in a single string per row in the .csv file, how can I print it in a cell per field in the .csv file? I attach images and code for more clarity with the problem. Thanks
<pre lang="C#"> public partial class CS : System.Web.UI.Page {
protected void ExportCSV(object sender, EventArgs e)
{
string constr = ConfigurationManager.ConnectionStrings["PRUEBASConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT * FROM Customers"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
//Build the CSV file data as a Comma separated string.
string csv = string.Empty;
foreach (DataColumn column in dt.Columns)
{
//Add the Header row for CSV file.
csv += column.ColumnName + ',';
}
//Add new line.
csv += "\r\n";
foreach (DataRow row in dt.Rows)
{
foreach (DataColumn column in dt.Columns)
{
//Add the Data rows.
csv += row[column.ColumnName].ToString().Replace(",", ";") + ',';
}
//Add new line.
csv += "\r\n";
}
//Download the CSV file.
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=SqlExport.csv");
Response.Charset = "";
Response.ContentType = "application/text";
Response.Output.Write(csv);
Response.Flush();
Response.End();
}
}
}
}
} }
|
|
|
|
|
We have embedded different visuals from a PBIX file onto a asp.net core razor view.
We have achieved that when a user clicks on a row in a table visual, detect the item and corssfilter the other embedded visuals as the user clicks.
On the Power BI environment you can do the same, but by pressing the CTRL key, you can select multiple rows and then it will filter the whole visuals on that page.
As we achieved the crossfiltering selecting just one we thought it would do the same by pressing CTRL, the problem is that PowerBI Embedded visual is not detecting the CTRL key and it is not actually detecting that we are selecting more than one row and it changes the whole filters to the first selected row.
|
|
|
|
|
|
|
Hello,
I am looking for an approach sanitize all string coming from the browser to my application where I won't have to modify all action methods on all controllers.
Maybe add a filter on the controller itself?
Welcoming suggestions.
Thank you!!
|
|
|
|
|
That seems like a bad idea to me. You shouldn't be storing "sanitised" values; you should be storing the raw values, and encoding them properly when you output them. The encoding will vary depending on where you're outputting them, so storing a single "sanitised" version of the value wouldn't help.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes, I want to encode when I am outputting but wondering whether there is a way where I change once and it applies everywhere.
I had the OnActionExecuted filter in mind but feel like there could be a better way.
|
|
|
|
|
Apologies if you've seen this before in the Net Core section ( deleted now ), I decided here is a better fit
How can I freeze the column header row of a table so that its always visible ?
Despite googling for hours I can't find a way to do this, I wan't the table header to be frozen ( as you can do in Excel ) any ideas guys ?
"Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
|
|
|
|
|
Add position:sticky;top:0; to the cells in the table header:
.table-frozen thead th,
.table-frozen thead td {
position: sticky;
top: 0;
background: white;
} (The background colour is required to prevent the body cells from bleeding through when the table is scrolled.)
Unfortunately, you can't apply it to the <thead> or <tr> :
Position Sticky and Table Headers | CSS-Tricks - CSS-Tricks[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Tried that Richard but no joy, there is a navbar above the table that maybe has some bearing on things
Edit
I commented out the navbar and your solution works - I have the navbar always visible and fixed to the top so it must be interfering
"Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
modified 24-Feb-22 9:01am.
|
|
|
|
|
How is it fixed to the top, and does it have a fixed height?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Probably easier to post _layout.cshtml
<!DOCTYPE html>
@inject IOptions<RestFactorySettings> Options;
@inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment env;
@using System.Runtime.Versioning;
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
<link href="~/lib/bootstrap/dist/css/bootstrap.css" rel="stylesheet" />
<link href="~/css/commands.css" rel="stylesheet" />
<link href="~/css/site.css" rel="stylesheet" />
<script src="~/js/DigitalClock.js"></script>
</head>
<body>
<div class="fixed-top">
<div class="container">
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<ul class="navbar-nav">
<li class="nav-item">
<a asp-action="GetCommands" asp-controller="Commands" class="nav-link">Commands</a>
</li>
<li class="nav-item">
<a asp-action="GetPlatforms" asp-controller="Platform" class="nav-link">Platforms</a>
</li>
<li class="nav-item">
<a asp-action="GetSiteDetails" asp-controller="Utils" class="nav-link">Site</a>
</li>
<li class="nav-item">
<a asp-action="GetActions" asp-controller="Utils" class="nav-link">Actions</a>
</li>
<li class="nav-item">
<a asp-action="GetClues" asp-controller="CCC" class="nav-link">CCC</a>
</li>
<li class="nav-item">
<a asp-action="GetSolverStats" asp-controller="CCC" class="nav-link">Solvers</a>
</li>
<li class="nav-item">
<a asp-action="GetComposerStats" asp-controller="CCC" class="nav-link">Composers</a>
</li>
<li class="nav-item">
<a asp-action="GetWord" asp-controller="RapidAPI" class="nav-link">Get Definition</a>
</li>
<li class="nav-item">
<a asp-action="GetRandomWord" asp-controller="RapidAPI" class="nav-link">Random Word</a>
</li>
</ul>
</nav>
</div>
</div>
<div class="container">
@RenderBody()
@RenderSection("OptionalStuff", false)
</div>
<br/>
</body>
</html>
"Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
|
|
|
|
|
That makes it tricky - the fixed top navbar appears on top of the sticky table header, and doesn't have a fixed height. I suspect you'll need some Javascript to fix that:
.table-frozen thead th,
.table-frozen thead td {
position: sticky;
top: var(--content-top, 0);
background: white;
}
body {
padding-top: var(--content-top, 0);
}
const updateNavbarHeight = function(){
const navbar = document.querySelector(".fixed-top");
const top = navbar.offsetHeight;
document.documentElement.style.setProperty("--content-top", `${top}px`);
};
document.addEventListener("DOMContentLoaded", function(){
updateNavbarHeight();
const ro = new ResizeObserver(() => updateNavbarHeight());
ro.observe(document.documentElement);
}); Demo[^]
ResizeObserver - Web APIs | MDN[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Getting out of my html depth here , do I just set the class of my table to table-frozen,add the js and leave everything else as is ? thanks for your patience
"Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
|
|
|
|
|
You'll need to add the JS and CSS, and then add the table-frozen class to your table.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|