ict.ken.be

 

Posts in Category: .Net

Example Messagent dynamic page with c# 

Categories: .Net Messagent
Website with registration
designer - select a date

<FORM method=post name=silentboxesform action=[$=PROBE(200)/]>
<DIV id=MASECTION contentEditable=true MACONSTRAINT="DATA_ERROR<>''" MASHOWALLLANGUAGES="FALSE">
<B>Kies een datum...</B>
<P>~DYNAMIC_RADIOLIST~</P>
<INPUT style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; WIDTH: 78px; BACKGROUND: url(http://messagent.yourinstallation.be/images/Residential/Adhoc/2008/2008-05/silent%20boxes/btn.gif); HEIGHT: 24px; COLOR: #7a7a7a; FONT-SIZE: 9px; BORDER-TOP: 0px; FONT-WEIGHT: bold; BORDER-RIGHT: 0px" value=Verdergaan alt=Verdergaan type=submit>
</DIV>
</FORM>


timeslots.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
 using (var con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]))
 {
         con.Open();

                var sbQuery = new StringBuilder();
                sbQuery.Append("select year(dag) as jaar, month(dag) as maand, day(dag) as dag, min(id) as slotid");
                sbQuery.Append(" from timeslots");
                sbQuery.Append(" where fk_user_id is null");
                sbQuery.Append(" and DatePart(hour, dag) < 12");
                sbQuery.Append(" group by year(dag), month(dag), day(dag)");

                bool hasVoormiddag = false;

                using (var cmd = new SqlCommand(sbQuery.ToString(), con))
                {
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (dr != null)
                        {
                            hasVoormiddag = true;

                            Response.Write("Voormiddag : <br />");

                            while (dr.Read())
                            {
                                Response.Write(
                                    "<input type='radio' name='slot' value='" + dr["slotid"] + "' onclick=\"new Effect.BlindDown($('internetDiv'),'blind', {duration:0.3});\" /> " + dr["dag"] + " september");
                                Response.Write("<br />");
                            }
                        }
                    }
                }

                sbQuery = new StringBuilder(); 
                sbQuery.Append(" select year(dag) as jaar, month(dag) as maand, day(dag) as dag, min(id) as slotid");
                sbQuery.Append(" from timeslots");
                sbQuery.Append(" where fk_user_id is null");
                sbQuery.Append(" and DatePart(hour, dag) > 12");
                sbQuery.Append(" group by year(dag), month(dag), day(dag)");

                if (hasVoormiddag) Response.Write("<br />");
               
                using (var cmd = new SqlCommand(sbQuery.ToString(), con))
                {
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (dr != null)
                        {
                            Response.Write("Namiddag : <br />");

                            while (dr.Read())
                            {
                                Response.Write(
                                    "<input type='radio' name='slot' value='" + dr["slotid"] + "' onclick=\"new Effect.BlindDown($('internetDiv'),'blind', {duration:0.3});\" /> " + dr["dag"] + " september");
                                Response.Write("<br />");
                            }
                        }
                    }
                }

            }
}

Website with registration

Configuration of pools and asp.net 

Categories: .Net IIS

.Net 4 repair

  • winver.exe
  • %windir%\Microsoft.NET\Framework64\v4.0.30319\SetupCache\Client\setup.exe /repair /x86 /x64 /ia64 /parameterfolder Client /norestart
  • %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe –i

Setting up permissions and pools on iis (eg. mojoPortal)

  • Create a new Web Site in IIS and name it mojoportal, leave the IP address as "All Unassigned" but add the host name "mojoportal"
  • Point the web site root to the mojoportal folder and choose a .NET 4 Integrated application pool. 
  • Make note of the user that is the identity on the application pool
  • In Windows Explorer, right click the mojoportal folder and choose properties, on the security tab click Edit..., then click Add..., then click Advanced..., then click Find Now
  • Select the user that is the identity on the application pool, then click OK, give the user read permissions here and click OK.

Cache insert vs add 

Categories: .Net

Cache.Add

Calling the Add method returns an object that represents the cached item. If the key already exists in the Cache the method will fail.

Cache.Insert

Calling the Insert method does not return an object. If the key already exists in the Cache it will overwrite the copy in the Cache.

Fix for pages that contain a lot of POST data 

Categories: .Net

<appSettings>

<add key="aspnet:MaxHttpCollectionKeys" value="1001" />

</appSettings>

A security update of Microsoft aspnet breaks pages that contain more then 1000 post items. If you have pages likes this, the web.config key will fix it. Then again, maybe better to change the page?

Microsoft recently (12-29-2011) released an update to address several serious security vulnerabilities in the .NET Framework. One of the fixes introduced by MS11-100 temporarily mitigates a potential DoS attack involving hash table collisions. It appears this fix breaks pages that contain a lot of POST data.

If your application stashes page information into ASP.NET ViewState, and exceeds the web server threshold, you're going to run into this problem. Rather than applying the web.config fix problem straight away you might want to take a look at optimizing your code first.

more on stackoverflow

 
Page 4 of 5 << < 1 2 3 4 5 > >>