Capturing SOAP requests to an ASP.NET ASMX web service

You can also implement by placing the code in Global.asax.cs protected void Application_BeginRequest(object sender, EventArgs e) { // Create byte array to hold request bytes byte[] inputStream = new byte[HttpContext.Current.Request.ContentLength]; // Read entire request inputstream HttpContext.Current.Request.InputStream.Read(inputStream, 0, inputStream.Length); //Set stream back to beginning HttpContext.Current.Request.InputStream.Position = 0; //Get XML request string requestString = ASCIIEncoding.ASCII.GetString(inputStream); } I … Read more

How to run ‘dotnet dev-certs https –trust’?

On Ubuntu the standard mechanism would be: dotnet dev-certs https -v to generate a self-signed cert convert the generated cert in ~/.dotnet/corefx/cryptography/x509stores/my from pfx to pem using openssl pkcs12 -in <certname>.pfx -nokeys -out localhost.crt -nodes copy localhost.crt to /usr/local/share/ca-certificates trust the certificate using sudo update-ca-certificates verify if the cert is copied to /etc/ssl/certs/localhost.pem (extension changes) … Read more

How ViewBag in ASP.NET MVC works

ViewBag is of type dynamic but, is internally an System.Dynamic.ExpandoObject() It is declared like this: dynamic ViewBag = new System.Dynamic.ExpandoObject(); which is why you can do : ViewBag.Foo = “Bar”; A Sample Expander Object Code: public class ExpanderObject : DynamicObject, IDynamicMetaObjectProvider { public Dictionary<string, object> objectDictionary; public ExpanderObject() { objectDictionary = new Dictionary<string, object>(); } … Read more

Url.Action parameters?

The following is the correct overload (in your example you are missing a closing } to the routeValues anonymous object so your code will throw an exception): <a href=”https://stackoverflow.com/questions/6278694/<%: Url.Action(“GetByList”, “Listing”, new { name = “John”, contact = “calgary, vancouver” }) %>”> <span>People</span> </a> Assuming you are using the default routes this should generate the … Read more

How do I make a checkbox required on an ASP.NET form?

javascript function for client side validation (using jQuery)… function CheckBoxRequired_ClientValidate(sender, e) { e.IsValid = jQuery(“.AcceptedAgreement input:checkbox”).is(‘:checked’); } code-behind for server side validation… protected void CheckBoxRequired_ServerValidate(object sender, ServerValidateEventArgs e) { e.IsValid = MyCheckBox.Checked; } ASP.Net code for the checkbox & validator… <asp:CheckBox runat=”server” ID=”MyCheckBox” CssClass=”AcceptedAgreement” /> <asp:CustomValidator runat=”server” ID=”CheckBoxRequired” EnableClientScript=”true” OnServerValidate=”CheckBoxRequired_ServerValidate” ClientValidationFunction=”CheckBoxRequired_ClientValidate”>You must select this box … Read more

How to find controls in a repeater header or footer

As noted in the comments, this only works AFTER you’ve DataBound your repeater. To find a control in the header: lblControl = repeater1.Controls[0].Controls[0].FindControl(“lblControl”); To find a control in the footer: lblControl = repeater1.Controls[repeater1.Controls.Count – 1].Controls[0].FindControl(“lblControl”); With extension methods public static class RepeaterExtensionMethods { public static Control FindControlInHeader(this Repeater repeater, string controlName) { return repeater.Controls[0].Controls[0].FindControl(controlName); } … Read more

ASP.Net Master Page and File path issues

You could use a ScriptManager: <asp:ScriptManager ID=”ScriptManager1″ runat=”server”> <Scripts> <asp:ScriptReference Path=”https://stackoverflow.com/questions/697660/~/jquery.js” /> </Scripts> </asp:ScriptManager> EDIT: If you absolutely need this in your <head> section, you could do something like: <head> <script type=”text/javascript” src=”https://stackoverflow.com/questions/697660/<%= Page.ResolveClientUrl(“https://stackoverflow.com/questions/697660/~/jquery.js”) %>”></script> </head> EDIT 2: According to the comments, if you are observing that The Controls collection cannot be modified because the … Read more