|
Thanks for the reply, Richard.
I have visited the page you linked in my many travels on the subject but I quickly became unclear about how Razor could in any way stand alone from MVC. Having looked again at the page, I note that there is a separate link for Razor using MVC so I guess that implies what I am looking for is also contained somewhere in that section of MSDN.
I'll do more research. I was just hoping to get a few informed comments about my general approach since I don't have too much free time to spend on this and ideally don't want to waste what time I do have wandering down a blind alley.
Thanks again for your reply.
- Patrick
Thank you to anyone taking the time to read my posts.
|
|
|
|
|
Razor is a view engine, just as ASPX is a view engine.
The main difference between the two is that ASPX was developed based on the web-forms page model and was adapted for use with MVC.
Razor, on the other hand; was built atop the MVC page model and there has been no official adaptation to any other page modeling.
There was a Codeplex project for Razor, now on GIT; and a couple years old:
GitHub - Antaris/RazorEngine: Open source templating engine based on Microsoft's Razor parsing engine
There is also a 2-part blog set about how it's put together
Dissecting Razor, part 1: Parts of the framework – SLaks.Blog
With your personal website, I would probably just build an empty MVC project and just fill the Views with your static HTML. Not the most efficient way to do it, however; you will have the framework present to start learning Razor and MVC.
As for Blazor, it still is a little young and I don't see too much going on with it to build/promote this.
Director of Transmogrification Services
Shinobi of Query Language
Master of Yoda Conditional
|
|
|
|
|
That's very helpful! Thank you!
I'll take some time to digest what you've written and I'm sure I'll be better informed to decide upon a way forward.
- Patrick
Thank you to anyone taking the time to read my posts.
|
|
|
|
|
Hi All,
I am little (a lot in fact) hazy on ASP.NET authentication methods...
At any rate I am trying to diagnose the following problem on an existing web app that use OpenID to query our ADFS server to authenticate users.
We followed that process:
https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/operations/configuring-alternate-login-id
And the AlternateLoginID is a custom LDAP attribute (namely interactUsername )
With some custom C# code I created a an AD user with the following properties:
UPNLogon: IU-3762@licensys.com
SAMAccountName: dev\IU-3762
interactUsername: llandersxA
when I try to login with llandersxA on the ADFS login page, it tells me:
Incorrect user ID or password. Type the correct user ID and password, and try again.
And replace the user name I entered (llandersxA ) with dev\llandersxA before trying again (which is not recognised either)
Any idea on what I might be missing? or link that could help on that topic?
Cheers!
[EDIT] the plot thickens!
If the interactUsername looks like an email, say llanderxA@foo.bar it works!
modified 4-Mar-19 22:33pm.
|
|
|
|
|
When developing (a relatively simple) web page, what is the best way to add a menu to it. I noticed that the HTML tag <menu> has been depreciated. I also see that it has been brought back in HTML 5.0 so I am a bit confused. Please comment. Also could somebody point me to a good tutorial on menus in HTML?
Thanks,
Bob
|
|
|
|
|
You may want to consider looking a Bootstrap for developing web pages.
A good reference site is: W3schools.com
|
|
|
|
|
jQuery has a nice and easy menu.
Look in the jQuery UI.
It helps if you have knowledge of javascript and css. (before you download the library, you can define your own custom stylesheet attached to it)
of course there are other libraries or you can download pure html/css examples.
|
|
|
|
|
If you're asking what is the easiest way to implement then consider comments above. Although there is a belief that it's not necessary to load a huge CSS framework or JS library for such a simple task (keep in mind that not all users access your site from a laptop or via good internet, so huge CSS/JS libraries may cause unresponsiveness for quite a long amount of time which will negatively affect UX).
If you're asking instead what is the most appropriate HTML tag - consider nav
Although you can really get away without it, the whole HTML5 thing is about tags that have some semantics behind them, showing what the part of a markup really does.
|
|
|
|
|
I'm using a WebAPI in my app. When I run it, the browser opens. When I stop the app, the browser closes...
...at least it USED to. Now the browser stays open.
I have no idea what changed. Anyone know what this is?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I have datalist with imageButton generated from folder with Images. I am trying to change border on clientClick event to indicate that user selected that image. I was able to get click event for image but how to I unselect others images?
function ccSelectedImage(e) {
{
alert(e);
e.style.border = "1px solid Red";
return false;
}
}
<asp:datalist id="dtlist" runat="server" repeatcolumns="20" cellpadding="1">
<itemtemplate>
<asp:imagebutton id="Image1" runat="server" bordercolor="White" onclientclick="ccSelectedImage(this); return false;"
="" imageurl="<%# Bind("Name", "~/Images/{0}") %>">
Dim dir As DirectoryInfo = New DirectoryInfo(MapPath("Images"))
Dim files As FileInfo() = dir.GetFiles()
Dim listItems As ArrayList = New ArrayList()
For Each info As FileInfo In files
listItems.Add(info)
Next
dtlist.DataSource = listItems
dtlist.DataBind()
|
|
|
|
|
I have a controller called Operator. In it I have these two methods:
[HttpGet]
public Response<IEnumerable<OperatorEntity>> GetAllOperators()
{
return GetBL().GetAll();
}
[HttpGet]
public Response<OperatorEntity> GetOperator(Guid id)
{
return GetBL().Get(id);
}
In my WPF app I call this:
Response<List<OperatorEntity>> getAllOpsResponse = await _operatorWebAPIProxy.GetAllOperatorsAsync();
Note that I'm calling GetAllOperatorsAsync
The call fails with the message
The request is invalid.The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Guid' for method 'RemoteServices.Shared.Classes.Response`1[RemoteServices.Shared.Entities.OperatorEntity] GetOperator(System.Guid)' in 'RemoteServices.ServicesWebAPI.Controllers.OperatorController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
The message is saying that it's trying to reach GetOperator, not GetAllOperatorsAsync.
The URL I'm passing is http://localhost:53122/api/Operator/GetAllOperators/
This was working yesterday. This morning, the only change was me removing and re-adding the web API project. I copied the controller classess out, removed the Web API Project, re-added it and the two controllers, and this started.
Anyone know what's going on?
[UPDATE]
I have multiple GET methods in my controller. Fix is here.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 1-Mar-19 14:17pm.
|
|
|
|
|
Sample Web Application with Login Form . On User log in capture the Ip Address , Host Name and store in database.
|
|
|
|
|
... and your question is?
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Every other framework will have its own services and components. In some frameworks (most modern frameworks, like Node.js, ASP.NET Core) you might be able to capture it automatically inside the request object. In other frameworks, you might have to add some other third-party libraries.
As far as the database component is concerned, you will need to check the runtime and its services for database. Again, all this depends highly on the runtime and framework.
If you don't know the runtime or framework, or have not yet chosen any, then a Google query can yield several results with this project sample, open sourced somewhere. Good luck.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
So there I was, writing some MVC code, when I installed jquery-ui through nuget.
I added the .min.js file to my startup bundles, and ran the app. I go the error
t.widget is not a function.
After making double-damn sure I had specified the correct path and spelled the filename correctly, I decided to see if the non .min file would work, and waddaya know - it did!
Does anyone know what's going on with this? At first, I figured it might be banging heads with jquery, but jquery would have been updated by nuget if it was necessary.
If I remember correctly, I'm using jquery-ui 1.12.1, if that matters.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
modified 25-Feb-19 7:35am.
|
|
|
|
|
This one?
NuGet Gallery | jQuery.UI.Combined 1.12.1[^]
I can't see anything obviously wrong with it. Did you definitely include the main jQuery library (v1.7 or later) first?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Nuget will update dependancies (I was already using 1.9), but why would the non-minified version work if that was the problem.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
OK, how are you defining the bundle? I've just tried:
bundles.Add(new ScriptBundle("~/bundles/jquery-ui").Include(
"~/Scripts/jquery-ui-{version}.min.js")); and it doesn't include the jQuery UI script in the rendered output, which would mean jQuery.widget wouldn't be defined.
Explicitly specifying the version number works:
bundles.Add(new ScriptBundle("~/bundles/jquery-ui").Include(
"~/Scripts/jquery-ui-1.12.1.min.js"));
Otherwise, do you have a stack trace from the error? And have you tried clearing your browser's cache?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: Explicitly specifying the version number works:
Well, that seems kinda counter to the way it's supposed to work (based on everything i know about bundles, which admittedly ain't much).
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
You could log it as a bug on GitHub, but I wouldn't hold my breath waiting for a fix.
Issues · aspnet/AspNetWebOptimization · GitHub[^]
If you leave the .min off, and then enable optimizations, it should automatically pick up the .min file:
bundles.Add(new ScriptBundle("~/bundles/jquery-ui").Include(
"~/Scripts/jquery-ui-{version}.js"));
BundleTable.EnableOptimizations = true;
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi
I try to build a shopping list, based in this tutorial.
https://code.tutsplus.com/tutorials/build-a-shopping-cart-in-aspnet--net-1663
For this i have a product, ShoppingCart and CartItem classes. When i test this build, this show everything ok between the classes but my problem begin when i change the product page to Shopping cart page. This not show data.
My Product Class
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
namespace mrosite
{
public class Product
{
public int PCode { get; set; }
public string PartNumber { get; set; }
public string Description { get; set; }
public int Available { get; set; }
public decimal Price { get; set; }
public Product(int pcode)
{
this.PCode = pcode;
string SqlStr = "SELECT [PCode], [PartNumber], [Description], [PStock], [Price] FROM Products WHERE PCode=@PCode";
DataSet SqlDs = new DataSet();
SqlCommand SqlCmd = new SqlCommand(SqlStr);
String connStr = ConfigurationManager.ConnectionStrings["TOOLCRIB"].ConnectionString;
SqlConnection SqlConn = new SqlConnection(connStr);
SqlDataAdapter SqlAdap = new SqlDataAdapter();
SqlCmd.CommandType = CommandType.Text;
SqlCmd.Parameters.AddWithValue("@PCode", PCode);
SqlCmd.Connection = SqlConn;
SqlAdap.SelectCommand = SqlCmd;
SqlAdap.Fill(SqlDs, "Prod");
SqlConn.Close();
this.PCode= Convert.ToInt32(SqlDs.Tables["Prod"].Rows[0][0]);
this.PartNumber = SqlDs.Tables["Prod"].Rows[0][1].ToString();
this.Description = SqlDs.Tables["Prod"].Rows[0][2].ToString();
this.Available = Convert.ToInt32(SqlDs.Tables["Prod"].Rows[0][3]);
this.Price = Convert.ToDecimal(SqlDs.Tables["Prod"].Rows[0][4]);
}
}
}
My ShoppingCart class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace mrosite
{
public class ShoppingCart
{
#region Properties
public List<CartItem> Items { get; private set; }
#endregion
#region Singleton Implementation
public static readonly ShoppingCart Instance;
static ShoppingCart()
{
if (HttpContext.Current.Session["ASPNETShoppingCart"] == null)
{
Instance = new ShoppingCart();
Instance.Items = new List<CartItem>();
HttpContext.Current.Session["ASPNETShoppingCart"] = Instance;
}
else
{
Instance = (ShoppingCart)HttpContext.Current.Session["ASPNETShoppingCart"];
}
}
protected ShoppingCart() { }
#endregion
#region Item Modification Methods
public void AddItem(int pCode)
{
CartItem newItem = new CartItem(pCode);
if (Items.Contains(newItem))
{
foreach (CartItem item in Items)
{
if (item.Equals(newItem))
{
item.Quantity++;
return;
}
}
}
else
{
newItem.Quantity = 1;
Items.Add(newItem);
}
}
public void SetItemQuantity(int pCode, int quantity)
{
if (quantity == 0)
{
RemoveItem(pCode);
return;
}
CartItem updatedItem = new CartItem(pCode);
foreach (CartItem item in Items)
{
if (item.Equals(updatedItem))
{
item.Quantity = quantity;
return;
}
}
}
public void RemoveItem(int pCode)
{
CartItem removedItem = new CartItem(pCode);
Items.Remove(removedItem);
}
#endregion
#region Reporting Methods
public decimal GetSubTotal()
{
decimal subTotal = 0;
foreach (CartItem item in Items)
subTotal += item.TotalPrice;
return subTotal;
}
#endregion
}
}
My CartItem Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace mrosite
{
public class CartItem : IEquatable<CartItem>
{
#region Properties
public int Quantity { get; set; }
private int _productId;
public int ProductId
{
get { return _productId; }
set {
_product = null;
_productId = value;
}
}
private Product _product = null;
public Product Prod
{
get {
if (_product == null) {
_product = new Product(ProductId);
}
return _product;
}
}
public string PartNumber
{
get { return Prod.PartNumber; }
}
public string Description {
get { return Prod.Description; }
}
public int Available
{
get { return Prod.Available; }
}
public decimal UnitPrice {
get { return Prod.Price; }
}
public decimal TotalPrice {
get { return UnitPrice * Quantity; }
}
#endregion
public CartItem(int productId) {
this.ProductId = productId;
}
public bool Equals(CartItem item) {
return item.ProductId == this.ProductId;
}
}
}
In this part, I send the product to shopping Cart from my Browse products site
protected void GrdBrowse_RowCommand1(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "SendCart")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GrdBrowse.Rows[index];
int myId = Convert.ToInt32(row.Cells[1].Text);
Product Prod = new Product(Convert.ToInt32(row.Cells[1].Text));
ShoppingCart.Instance.AddItem(Prod.PCode);
Response.Redirect("ViewCart.aspx");
This is the Shopping Cart class but this not show data
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="BrowseProducts.aspx.cs" Inherits="mrosite.BrowseProducts" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<div class="jumbotron">
<h1>Product Finder</h1>
<p class="lead">Search your product according with your keyword</p>
<p>
<asp:TextBox ID="txtScr" runat="server" Width="310px"></asp:TextBox>
<a><asp:Button ID="btnSearch" CssClass="btn btn-primary btn-lg" runat="server" Text="Search" Height="42px" Width="123px" OnClick="btnSearch_Click" /></a>
</p>
</div>
<div class="container">
<h3>Results...</h3>
<p>
<asp:Label ID="lblResults" runat="server" Text="0 Results for: none" ForeColor="Red"></asp:Label></p>
<p><asp:Label ID="lblShowing" runat="server" Text="0 Showing results: none" ForeColor="GrayText"></asp:Label>
</p>
<p>
<asp:GridView ID="GrdBrowse" runat="server" AutoGenerateColumns="False" AllowPaging="True" PageSize="10" EmptyDataText="There is nothing in the product list." GridLines="None" Width="100%" CellPadding="5" ShowFooter="true"
DataKeyNames="PCode" OnPageIndexChanging="GrdBrowse_PageIndexChanging" OnRowCommand="GrdBrowse_RowCommand1" >
<HeaderStyle HorizontalAlign="Left" BackColor="#3D7169" ForeColor="#FFFFFF" />
<FooterStyle HorizontalAlign="Right" BackColor="#6C6B66" ForeColor="#FFFFFF" />
<AlternatingRowStyle BackColor="#F8F8F8" />
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Image runat="server" DataImageUrlField="Picture" HeaderText="Picture" ControlStyle-Width="75px" ControlStyle-Height ="75px">
</asp:Image>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="PCode" HeaderText="Product Code" />
<asp:BoundField DataField="PN" HeaderText="Part Number" />
<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:BoundField DataField="Available" HeaderText="Available" />
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:TextBox ID="txtQty" runat="server" Columns="5" Text="0"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Button Text="Add to Cart" runat="server" CommandName="SendCart" CommandArgument="<%# Container.DataItemIndex %>" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</p>
</div>
</asp:Content>
Can you help me with this detail?
Thanks and regards.
|
|
|
|
|
We usually add white spaces in HTML to make readable
Example –
Development Version:
<div>
Title
</div>
When above code is minimized (for prod build), we get following output
<div>Title</div>
Now, consider we have a pseudo elements added to class “surround-brackets”. Following is the CSS
.surround-brackets::before {
content: "(";
}
.surround-brackets::after {
content: ")";
}
Please check fiddle here - Fiddle[^]
Any suggestions how to avoid such issues ?
Aditya.
|
|
|
|
|
How about adding the white-space in the generated content?
.surround-brackets::before {
content: "( ";
}
.surround-brackets::after {
content: " )";
}
Updated fiddle[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have a controller with a parameter that is List<string>. The parameter is always null.
Controller
[HttpGet]
public List<string> GetOperatorsNotOnServer(List<string> instrumentOperators)
{
var bl = GetBusinessLayer();
var results = bl.GetOperatorsNotOnServer(instrumentOperators);
return results;
}
I've tried using an array with the same result. What's the right way to pass a list of string to a controller?
UPDATE
When I changed the controller method from [HttpGet] to [HttpPost] it now works. I don't understand why, but it's now working. Can someone explain this to me?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 12-Feb-19 12:51pm.
|
|
|
|
|
Probably related to this:
If the parameter is a "simple" type, Web API tries to get the value from the URI.
For complex types, Web API tries to read the value from the message body
A List<T> isn't counted as a "simple" type. If you add the [FromUri] attribute to the parameter, then it should work.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|