|
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
|
|
|
|
|
I tried that already. The parameter is a list, but its empty. The data doesn't make it across.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
HttpGet is generally for when the page first loads, that's the method it will call. HttpPost is when the page is a form post, ie the result of someone pressing a Submit button. The instrumentOperators are probably defined in your form, so are available in an httppost but not an httpget.
|
|
|
|
|
This is a bit long but I'm stuck. Working on a WPF app hitting an ASP.NET Web API.
Not sure why but I started getting this message. I haven't changed the API recently.
The entity is posted at the bottom. Seems like the controller can't deserialize byte arrays. When I removed 2 byte[] properties from my model, the error stopped.
With the byte[] properties included I have...
Operator Controller
[HttpGet]
public IEnumerable<OperatorEntity> GetAllOperators()
{
var bl = GetBusinessLayer();
var results = bl.GetAll();
return results;
}
Proxy
public async Task<T> ExecuteAsync<T>() where T : new()
{
URL = client.BaseUrl + request.Resource;
<pre>
IRestResponse<T> restResponse = await client.ExecuteTaskAsync<T>(request, new CancellationToken());
var result = (T)restResponse.Data;
if (!string.IsNullOrEmpty(restResponse.ErrorMessage))
{
throw new Exception(restResponse.ErrorMessage); // <==== THROWS "No parameterless constructor defined for this object"
}
else
{
if ((int)restResponse.StatusCode >= 299)
{
string message = string.Format("An error occured calling the WebAPI. {0} The status code is '{1}'. {2} The error message is {3}",
Environment.NewLine, restResponse.StatusCode, Environment.NewLine, restResponse.Content);
throw new Exception(message);
}
}
return result;
}
Caller
public async Task<List<OperatorEntity>> GetAllOperatorsAsync()
{
var webAPIExecutor = new WebAPIExecutor(ServerUrl, "/Operator/GetAllOperators/", Method.GET);
return await webAPIExecutor.ExecuteAsync<List<OperatorEntity>>();
}
Entity
<pre> [DataContract]
[Serializable]
public class OperatorEntity : _EntityBase
{
private bool _BuiltIn;
[DataMember]
public bool BuiltIn
{
get
{
return _BuiltIn;
}
set
{
if (_BuiltIn != value)
{
_BuiltIn = value;
RaisePropertyChanged("BuiltIn");
}
}
}
private bool _Active;
[DataMember]
public bool Active
{
get
{
return _Active;
}
set
{
if (_Active != value)
{
_Active = value;
RaisePropertyChanged("Active");
}
}
}
private string _FirstName;
[DataMember]
public string FirstName
{
get
{
return _FirstName;
}
set
{
if (_FirstName != value)
{
_FirstName = value;
RaisePropertyChanged("FirstName");
}
}
}
private string _LastName;
[DataMember]
public string LastName
{
get
{
return _LastName;
}
set
{
if (_LastName != value)
{
_LastName = value;
RaisePropertyChanged("LastName");
}
}
}
private string _Username;
[DataMember]
public string Username
{
get
{
return _Username;
}
set
{
if (_Username != value)
{
_Username = value;
RaisePropertyChanged("Username");
}
}
}
private string _Password;
[DataMember]
public string Password
{
get
{
return _Password;
}
set
{
if (_Password != value)
{
_Password = value;
RaisePropertyChanged("Password");
}
}
}
private DateTimeOffset? _PasswordChangedDate;
[DataMember]
public DateTimeOffset? PasswordChangedDate
{
get
{
return _PasswordChangedDate;
}
set
{
if (_PasswordChangedDate != value)
{
_PasswordChangedDate = value;
RaisePropertyChanged("PasswordChangedDate");
}
}
}
private DateTimeOffset? _LastLoginDate;
[DataMember]
public DateTimeOffset? LastLoginDate
{
get
{
return _LastLoginDate;
}
set
{
if (_LastLoginDate != value)
{
_LastLoginDate = value;
RaisePropertyChanged("LastLoginDate");
}
}
}
private byte[] _rowversion;
[DataMember]
public byte[] rowversion
{
get
{
return _rowversion;
}
set
{
if (_rowversion != value)
{
_rowversion = value;
RaisePropertyChanged("rowversion");
}
}
}
private short _RoleType;
[DataMember]
public short RoleType
{
get
{
return _RoleType;
}
set
{
if (_RoleType != value)
{
_RoleType = value;
RaisePropertyChanged("RoleType");
}
}
}
private byte[] _ESignature;
[DataMember]
public byte[] ESignature
{
get
{
return _ESignature;
}
set
{
if (_ESignature != value)
{
_ESignature = value;
RaisePropertyChanged("ESignature");
}
}
}
private string _Email1;
[DataMember]
public string Email1
{
get
{
return _Email1;
}
set
{
if (_Email1 != value)
{
_Email1 = value;
RaisePropertyChanged("Email1");
}
}
}
private string _Email2;
[DataMember]
public string Email2
{
get
{
return _Email2;
}
set
{
if (_Email2 != value)
{
_Email2 = value;
RaisePropertyChanged("Email2");
}
}
}
private bool _SendAlerts;
[DataMember]
public bool SendAlerts
{
get
{
return _SendAlerts;
}
set
{
if (_SendAlerts != value)
{
_SendAlerts = value;
RaisePropertyChanged("SendAlerts");
}
}
}
private short? _SendAlertsTime;
[DataMember]
public short? SendAlertsTime
{
get
{
return _SendAlertsTime;
}
set
{
if (_SendAlertsTime != value)
{
_SendAlertsTime = value;
RaisePropertyChanged("SendAlertsTime");
}
}
}
private bool _SendResults;
[DataMember]
public bool SendResults
{
get
{
return _SendResults;
}
set
{
if (_SendResults != value)
{
_SendResults = value;
RaisePropertyChanged("SendResults");
}
}
}
private short? _SendResultsTime;
[DataMember]
public short? SendResultsTime
{
get
{
return _SendResultsTime;
}
set
{
if (_SendResultsTime != value)
{
_SendResultsTime = value;
RaisePropertyChanged("SendResultsTime");
}
}
}
private bool _MonitoringSystemUser;
[DataMember]
public bool MonitoringSystemUser
{
get
{
return _MonitoringSystemUser;
}
set
{
if (_MonitoringSystemUser != value)
{
_MonitoringSystemUser = value;
RaisePropertyChanged("MonitoringSystemUser");
}
}
}
private bool _Email1AllowHtml;
[DataMember]
public bool Email1AllowHtml
{
get
{
return _Email1AllowHtml;
}
set
{
if (_Email1AllowHtml != value)
{
_Email1AllowHtml = value;
RaisePropertyChanged("Email1AllowHtml");
}
}
}
private bool _Email2AllowHtml;
[DataMember]
public bool Email2AllowHtml
{
get
{
return _Email2AllowHtml;
}
set
{
if (_Email2AllowHtml != value)
{
_Email2AllowHtml = value;
RaisePropertyChanged("Email2AllowHtml");
}
}
}
private bool _MonitoringSelf;
[DataMember]
public bool MonitoringSelf
{
get
{
return _MonitoringSelf;
}
set
{
if (_MonitoringSelf != value)
{
_MonitoringSelf = value;
RaisePropertyChanged("MonitoringSelf");
}
}
}
private bool? _IsLockedOut;
[DataMember]
public bool? IsLockedOut
{
get
{
return _IsLockedOut;
}
set
{
if (_IsLockedOut != value)
{
_IsLockedOut = value;
RaisePropertyChanged("IsLockedOut");
}
}
}
private bool? _IsActiveDirectory;
[DataMember]
public bool? IsActiveDirectory
{
get
{
return _IsActiveDirectory;
}
set
{
if (_IsActiveDirectory != value)
{
_IsActiveDirectory = value;
RaisePropertyChanged("IsActiveDirectory");
}
}
}
}
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
Thanks, I'll look into it
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Hello all. While trying to implement a web-socket handshake, I encountered a weird behavior. It looks like the HttpListenerResponse class doesn't send the 'Connection' header. Here is an example for explaining what I mean:
public void TestWebSocketHttpHandshake()
{
int port = 9444;
ManualResetEvent serverStartedEvent = new ManualResetEvent(false);
ManualResetEvent clientClosedEvent = new ManualResetEvent(false);
async Task RunHttpServer()
{
HttpListener hl = new HttpListener();
hl.Prefixes.Add($"http://+:{port}/");
hl.Start();
serverStartedEvent.Set();
HttpListenerContext hlc = await hl.GetContextAsync();
string secWebSocketKeyHeader = hlc.Request.Headers["Sec-WebSocket-Key"]?.Trim();
string secWebSocketAcceptHeader = Convert.ToBase64String(
System.Security.Cryptography.SHA1.Create().ComputeHash(
Encoding.UTF8.GetBytes(secWebSocketKeyHeader + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11")
)
);
hlc.Response.StatusCode = (int)HttpStatusCode.SwitchingProtocols;
hlc.Response.StatusDescription = "Switching Protocols";
hlc.Response.ProtocolVersion = new Version("1.1");
hlc.Response.AddHeader("Upgrade", "websocket");
hlc.Response.AddHeader("Connection", "Upgrade");
hlc.Response.AddHeader("Sec-WebSocket-Accept", secWebSocketAcceptHeader);
hlc.Response.Close();
clientClosedEvent.WaitOne();
hl.Stop();
}
async Task RunTcpClient()
{
const string eol = "\r\n";
serverStartedEvent.WaitOne();
using (TcpClient tc = new TcpClient())
{
tc.Connect("localhost", port);
using (NetworkStream ns = tc.GetStream())
{
string wsRequest =
$"GET /chat HTTP/1.1{eol}Host: localhost:{port}{eol}"+
$"Upgrade: websocket{eol}Connection: Upgrade{eol}" +
$"Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ=={eol}"+
$"Sec-WebSocket-Version: 13{eol}{eol}";
byte[] wsRequestBytes = Encoding.ASCII.GetBytes(wsRequest);
await ns.WriteAsync(wsRequestBytes, 0, wsRequestBytes.Length);
Console.WriteLine("Sent request:");
Console.WriteLine(wsRequest);
byte[] responseBuf = new byte[256];
int resBytesCount = await ns.ReadAsync(responseBuf, 0, responseBuf.Length);
string wsResponse = Encoding.ASCII.GetString(responseBuf, 0, resBytesCount);
Console.WriteLine("Received response:");
Console.WriteLine(wsResponse);
}
}
clientClosedEvent.Set();
}
Task.WaitAll(RunHttpServer(), RunTcpClient());
} The result is:
Sent request:
GET /chat HTTP/1.1
Host: localhost:9444
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Version: 13
Received response:
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Date: Mon, 11 Feb 2019 16:16:37 GMT So, what we can see here is that we have a HttpListener server that sets the 'Connection' header in the response but, when the client gets the server's response, the 'Connection' header is missing. I know that we can use the HttpListenerContext.AcceptWebSocketAsync method for handling the web-socket connection but, this method uses the operating system web-socket support that is supported only from Windows 8/ Windows Server 2012 and, we want this to work also on a Windows Server 2008 system. I know that there are some solutions on the web for running a web-socket server. But, all the solutions I found are for running a server that listens to web-socket requests on a given port. Since in my case I want to accept web-socket requests on the same port of an existing server (Owin server that does other things), I have to handle it using the given request's HttpListenerContext . Can anyone explain this behavior (the missing 'Connection' header) or, suggest a solution?
modified 11-Feb-19 14:27pm.
|
|
|
|
|
I'm working on an app that hits a Web API. Right not I'm developing in VS2017 using it's local IIS. Can I somehow configure this so that other PC's can access that web API for testing purposes?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
I went through his blog right before I posted. After adding the binding line to the .config, then running my app, I get
"Process with an Id of [some id] is not running."
Here's my config entries
<site name="RemoteServices.BusinessServices" id="6">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Projects\RemoteServices.BusinessServices" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:53175:localhost" />
<binding protocol="http" bindingInformation="*:53175:192.168.51.66"
</site>
I closed an reopened vs and my web api project failed to load. Commented out the line in the .config and everythign is back to normal.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Kevin Marois wrote: <binding protocol="http" bindingInformation="*:53175:192.168.51.66" //<I added this
Is that a typo in your question, or did you really miss out the closing /> from that element?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes, it was a typo. Fixed it and all works as expected.
Thank you again
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Richard,
I'm back to this again. I had this working and now it doesn't.
I went back & checked my work. I did the following:
IIS Config
<bindings>
<binding protocol="http" bindingInformation="*:53122:localhost" />
<binding protocol="http" bindingInformation="*:53125:192.168.51.66" />
</bindings>
I also ran
netsh http add urlacl url=http:
netsh advfirewall firewall add rule name="ePlex Remote Services" dir=in protocol=tcp localport=53125 profile=private remoteip=localsubnet action=allow
When I run the web api from my dev pc it works fine. But when I try to hit 192.168.51.66:53125 from another PC it can't find it.
I'm not sure how to debug this. Any thoughts?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Is the API project running when you try to access it from the remote PC?
Is the firewall's "private" profile active?
Is the remote PC on the same local subnet as your dev PC?
Try turning on logging for the firewall to see if that gives you any information:
How to Track Firewall Activity with the Windows Firewall Log[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Well, I fixed it, but I don't know what was wrong.
First, I went through all your suggestions. Still couldn't get it to work.
So I removed & recreated the Web API project, ran the steps from that blog, and bingo - back & and accessable remotely again.
Thanks for your help again.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I'm trying to call a method on my Operator controller called AddOperator
[HttpPost]
public void AddOperator(OperatorEntity entity)
{
var bl = GetBusinessLayer();
bl.Add(entity);
}
RestClient baseURl is "{http://localhost.fiddler:53175/api}"
The RestRequest.Resource is "/Operator/AddOperator/".
The RestRequest.Parameters collection has one entry which is an instance of the OperatorEntity.
Fiddler Output
GET http:
Accept: application/json, text/json, text/x-json, text/javascript, application/xml, text/xml, text/plain
User-Agent: RestSharp/106.6.7.0
Host: localhost:53175
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Notice the GET in the output.
I'm really new to WebAPI's, but I thought that I needed to mark the controller method with [HttpPost] , yet that doesn't seem to work.that
What am I doingwrong here?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
You do need to mark the method with [HttpPost] (or technically, [HttpPut] if this is a REST API).
The client call is using the wrong HTTP method.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
ya, that was it. Thank you sir!
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|