Tuesday, 24 October 2023

Hosting ASP.NET Web API REST Service On IIS 10

 To make any application accessible to the end-user, we need to host it on a server. So, in this article, we will learn how to host ASP.NET Web API REST Service in IIS 10. The following steps are required to host any application. 

I hope, you have learned how to create and publish ASP.NET Web API REST Service. Now, let's start hosting Web API REST Service in IIS 10.

Step 1 Install IIS
 
Before hosting any application, make sure that IIS (Internet Information Services) is installed on your Hosting Server. If it is not installed or enabled, then follow the below steps.
  • Click on Windows icon at the bottom left corner and find the "Control Panel" menu and click on it.

  • In the "Control Panel", find the "Program and Features" option from the displayed list.

  • This shows the list of installed programs. Find and click the "Turn Windows feature on or off" option from the left pane, as shown in the following image.

     
  • Now, in the next popup, find Internet Information Services (IIS) and check on it.
  • Click "Next" button and then "Finish". It takes a few minutes to install IIS.
  • After installing IIS, restart your machine.
Note - I have Windows 10 OS and the above process is for Windows 10 PC. The steps might differ depending on your Operating System version.
 
Step 2 Install .NET Framework
 
Although Visual Studio is not required on your hosting Server, it must have .NET Framework installed, as per the .NET framework used to develop the application. If it is not installed, then please install the appropriate .NET Framework available on Microsoft official website.
 
I assume, you have installed the .NET framework on your Hosting Server.
 
Step 3 Move the published code on Hosting Server
 
Copy the "Published files" and paste those on respective Servers where you want to host the Web API REST Service. In our last article, we published Web API REST Service in the E drive of my Server, as shown in the following image .
 
Step 4 Open IIS Manager
 
Now, open the IIS Manager from Windows menu or in any other ways you have known.

 
The above image is of IIS 10 Manager of my Windows 10 machine. The view as well as options might be different on your machine depending on the OS version.

Step 5 Add Website
 
Right click on "Site" in IIS and click on add new website, as shown in the following screenshot.
 

After clicking on "Add Website" option, it displays the following configuration window.
 
 
 
I hope you understood the preceding configuration by highlighted text.
 
Step 6 Define Site Name & Application Pool
 
Define the site name which will be useful to uniquely identify the site within the IIS Server. After specifying the site name, choose the Application Pool from available pools. You can even create a custom application pool with any desired name. Currently, our IIS Manager has the following Application Pools.

 
Choose the application pool depending on your application configuration. In this article, we are going to choose DefaultAppPool.

Step 7 Browse and select Published Folder path
 
Now, choose the physical location of published code files by clicking on "Browse" button, as shown in the following image. 
 
 
 
Now, click on "OK" button.
 
Step 8 Define IP address & Port
 
Choose one IP address from the list of available IP addresses and define the unique port number for the application, which will be unique within the defined IP address.

Step 9 Choose Protocol & Host name (optional )
 
Choose the protocol for your application i.e HTTP or HTTPS which requires port 443 to be open and choose the Host name which will be used publicly to access the application. After defining all the configurations, the web site configuration window will look like this.
 
 
Now, click on OK button. It will create and add the application in IIS.
 


Step 10 Browse the URL with REST Client
 
Browse the hosted application using REST client with base URL along with API, Controller name, and Action method name, with pattern defined in routing template inside the webapiconfig.cs file.
 
We can browse applications using the browser but then, we can only test the GET method. So, to test all types of Action Methods, we are using  advanced REST client which is a developer extension tool in Firefox browser.
 
Our hosted Web API REST Service includes these two methods, as given below.
  • GetAllEmployees (GET )
  • GetEmployeeById  (POST ) which takes id as input parameter
Browse GetAllEmployees method using Advanced REST client which has used HTTP GET verb.
 


In the preceding screenshot, the GetAllEmployees hosted Web API REST method is returning all the employee lists.
 
Now, browse GetEmployeeById method using Advanced REST client which uses HTTP POST verb and takes id as input parameter.
 
 
 
From the above desired output, it's clear that our Web API REST Service is hosted on IIS successfully.

Note
  • Download the Zip file of the Published code to learn and start quickly.
  • This article is just guideline to show how to host Web API REST Service on IIS .
  • Optimize the speed by setting debug as false etc., from web.config file as per your skills. 
  • In this article, the optimization is not covered in depth.
  • Configure the authentication in IIS as per your REST Service .

For more information: https://www.c-sharpcorner.com/article/hosting-asp-net-web-api-rest-service-on-iis-10/

Wednesday, 18 October 2023

Pinging a Reader with C#

 Here's a handy way to determine if a reader is connected to the network or not. It uses the .NET Ping and PingOptions classes, so make sure to add the following namespace to your project.

 

using System.Net.NetworkInformation;

//Then, you can write a method like this, that returns true if the reader is connected and false if it is not.

private bool ReaderIsAvailable(string address)
{
    Ping pingSender = new Ping();
    PingOptions options = new PingOptions();
    options.DontFragment = true;
    string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    byte[] buffer = Encoding.ASCII.GetBytes(data);
    int timeout = 120;
    PingReply reply = pingSender.Send(address, timeout, buffer, options);
    if (reply.Status == IPStatus.Success)
        return true;
    else
        return false;
}

Finally, this is how you would call the method.

if (ReaderIsAvailable("SpeedwayR-10-25-32"))
{
    // Reader is connected to the network.
    // Start reading some tags!
}
else
{
    // Reader is not connected to the network.
    // Handle it here.
}

Sunday, 8 October 2023

Android – Can’t make spinner’s scrollbar always visible (Android)

 I have such a problem – I want to make spinner's scrollbar always visible.

But for spinner function

setScrollbarFadingEnabled(false);

causes crash with a NullExceptionPointer during drawing the GUI.

XML tags can't solve this problem too – it seems that spinner just ignore them.

Maybe there are another ways to move? For example, using of the custom scrollbar? If yes, how can I do this?

---------------------------------------------------------------------------------------------------------------

As I've been asked, here is LogCat error message for simple project with just a spinner in it:

AndroidRuntime(2252): FATAL EXCEPTION: main
AndroidRuntime(2252): java.lang.NullPointerException
AndroidRuntime(2252): at android.view.View.onDrawScrollBars(View.java:5836)
AndroidRuntime(2252): at android.view.View.draw(View.java:6799)
AndroidRuntime(2252): at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
AndroidRuntime(2252): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
AndroidRuntime(2252): at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
AndroidRuntime(2252): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
AndroidRuntime(2252): at android.view.View.draw(View.java:6796)
AndroidRuntime(2252): at android.widget.FrameLayout.draw(FrameLayout.java:352)
AndroidRuntime(2252): at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
AndroidRuntime(2252): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
AndroidRuntime(2252): at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
AndroidRuntime(2252): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
AndroidRuntime(2252): at android.view.View.draw(View.java:6796)
AndroidRuntime(2252): at android.widget.FrameLayout.draw(FrameLayout.java:352)
AndroidRuntime(2252): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2078)
AndroidRuntime(2252): at android.view.ViewRoot.draw(ViewRoot.java:1433)
AndroidRuntime(2252): at android.view.ViewRoot.performTraversals(ViewRoot.java:1175)
AndroidRuntime(2252): at android.view.ViewRoot.handleMessage(ViewRoot.java:1753)
AndroidRuntime(2252): at android.os.Handler.dispatchMessage(Handler.java:99)
AndroidRuntime(2252): at android.os.Looper.loop(Looper.java:123)
AndroidRuntime(2252): at android.app.ActivityThread.main(ActivityThread.java:4632)
AndroidRuntime(2252): at java.lang.reflect.Method.invokeNative(Native Method)
AndroidRuntime(2252): at java.lang.reflect.Method.invoke(Method.java:521)
AndroidRuntime(2252): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
AndroidRuntime(2252): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
AndroidRuntime(2252): at dalvik.system.NativeStart.main(Native Method)

Best Solution

Spinner does not have a scrollbar, Hence you are getting NullPointerException.

The popup shown by spinner has a scrollbar. So you need to change the properties of the ListView shown by spinner. But ListView itself is not exposed by Spinner by any public methods.

Even if you get the ListPopupWindow by reflection, a further problem arises, that ListPopupWindow's ListView is only created after you click the Spinner.

But OnClickListener of the Spinner cannot be registered , to set the ListView Properties after the show.

You could create a Custom Spinner with performClick overridden and then get mPopup by reflection. and use mPopup.getListView().setScrollbarFadingEnabled(false)

But If you are going to create a custom Spinner, i believe it is easier to implement the whole popup to

Friday, 6 October 2023

How to always display vertical scrollbar in spinner when open it? Explain with example

 The vertical scrollbar in a Spinner widget in Android is typically displayed automatically when there are enough items in the Spinner to require scrolling. Android does not provide a built-in option to always display the vertical scrollbar when the Spinner is open. However, you can create a custom Spinner-like view that always shows the scrollbar when opened.

Here's an example of how you can achieve this by creating a custom Spinner-like view using a PopupWindow and a ListView:

  1. Create a Custom Spinner Layout:

    Create a custom layout for your Spinner-like view (e.g., custom_spinner_layout.xml). In this layout, you can include a ListView with vertical scrollbars. Here's a basic example:

-------------------------------------------------------------------------------------------------------

<!-- custom_spinner_layout.xml -->

<ListView

    android:id="@+id/customSpinnerListView"

    android:layout_width="match_parent"

    android:layout_height="wrap_content"

    android:scrollbars="vertical" />


---------------------------------------------------------------------------------------------------------------

Create a Custom Spinner Class:

Create a custom class (e.g., CustomSpinner) to manage the behavior of your custom Spinner-like view. In this class, you can create a PopupWindow to display the custom view:

-------------------------------------------------------------------------------------------------------------

import android.content.Context;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;

import android.widget.ArrayAdapter;

import android.widget.ListView;

import android.widget.PopupWindow;


import java.util.List;


public class CustomSpinner {

    private final Context context;

    private final PopupWindow popupWindow;

    private final ListView listView;


    public CustomSpinner(Context context, List<String> itemList) {

        this.context = context;

        View customView = LayoutInflater.from(context).inflate(R.layout.custom_spinner_layout, null);


        popupWindow = new PopupWindow(customView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

        popupWindow.setFocusable(true);

        listView = customView.findViewById(R.id.customSpinnerListView);

        ArrayAdapter<String> adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, itemList);

        listView.setAdapter(adapter);

    }

    public void show(View anchor) {

        popupWindow.showAsDropDown(anchor);

    }

    public void dismiss() {

        popupWindow.dismiss();

    }

}

-------------------------------------------------------------------------------------------------------------


Using the Custom Spinner:

In your activity, you can create an instance of the custom spinner and display it when needed. For example:

-------------------------------------------------------------------------------------------------------------

List<String> items = new ArrayList<>();

items.add("Item 1");

items.add("Item 2");

items.add("Item 3");


CustomSpinner customSpinner = new CustomSpinner(this, items);


// Display the custom spinner when a button is clicked

Button openSpinnerButton = findViewById(R.id.openSpinnerButton); // Replace with your button

openSpinnerButton.setOnClickListener(new View.OnClickListener() {

    @Override

    public void onClick(View v) {

        customSpinner.show(v);

    }

});


-------------------------------------------------------------------------------------------------------------

  1. In this example, when the button is clicked, the custom spinner is displayed, and it will always show vertical scrollbars when open.

By creating a custom Spinner-like view with vertical scrollbars, you can control the scrollbar's visibility and display it whenever the custom Spinner is opened.


Monday, 2 October 2023

Android spinner increment number

 public void addItemsOnSpinner() {


        spinner = (Spinner) findViewById(R.id.spinner);
        List<String> list = new ArrayList<String>();
        for (int i=0; i<=255; i++){
            list.add("list " + i);
        }
        ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_spinner_item, list);
        dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(dataAdapter);
    }

What is Formal Education? Explain with example.

 Formal education refers to structured and organized learning experiences that take place within an established institution, typically following a predefined curriculum, syllabus, and a set of rules and regulations. This type of education is characterized by its systematic approach, assessment methods, and the issuance of recognized certificates or degrees upon successful completion of the program.

Key features of formal education include:

  1. Institutionalized Setting: Formal education occurs in institutions such as schools, colleges, universities, and vocational training centers. These institutions have specific guidelines, schedules, and facilities dedicated to education.

  2. Structured Curriculum: Formal education follows a planned and structured curriculum that outlines what subjects or topics students should learn and in what order. This curriculum is often designed by education experts and approved by relevant authorities.

  3. Qualified Instructors: Trained and qualified teachers or professors lead formal education programs. They are responsible for imparting knowledge, providing guidance, and assessing students' progress.

  4. Assessment and Evaluation: Formal education involves regular assessments, examinations, and grading systems to measure students' understanding and performance. Grades and transcripts are used to evaluate and record their academic progress.

  5. Standardized Certification: Successful completion of formal education programs typically leads to the award of certificates, diplomas, or degrees, which are recognized and accepted by employers, other educational institutions, and society at large.

  6. Duration: Formal education programs have a specific duration or duration range, which can vary depending on the level of education (e.g., primary, secondary, tertiary) and the specific course or degree pursued.

Example of Formal Education:

Let's consider an example of formal education in the context of a university degree program:

Bachelor of Science in Computer Science

  • Institution: A university, such as XYZ University, offers a Bachelor of Science (B.Sc.) program in Computer Science.

  • Curriculum: The university has a predefined curriculum for this program, which includes courses in programming languages, algorithms, database management, and computer hardware, among others. Students are required to complete a certain number of credits in these courses.

  • Instructors: Qualified professors with expertise in computer science teach these courses, providing lectures, assignments, and lab sessions to students.

  • Assessment: Throughout the program, students are assessed through quizzes, assignments, mid-term exams, and final exams. Their performance is measured, and grades are assigned.

  • Certification: Upon successful completion of all required courses and meeting the university's graduation requirements, students are awarded a Bachelor of Science degree in Computer Science. This degree is recognized by employers and can be used as a qualification for various job opportunities in the field.

In summary, formal education is a structured and standardized form of learning that occurs within educational institutions, offering recognized qualifications upon completion. It plays a crucial role in providing individuals with the knowledge and skills needed to pursue careers and contribute to society.

Saturday, 30 September 2023

250 Voiceless TH Words, Phrases, Sentences, and Reading Passages

 

Initial Voiceless TH by Syllables


2
Syllable

thankful

thankless

thank you

theme song

thermal

thicken

thickness

thimble

thinking

thinner

third base

thirteen

thirty

thistle

thorny

thoughtful

thousand

thumbtack

thunder

Thursday

3
Syllable

thankfulness

thanksgiving

thank you card

thank you note

theater

theory

therapist

therapy

thermostat

thesaurus

thickener

thinkable

thinking cap

third baseman

thirty one - thirty eight

thoroughly

thunderbird

thundercloud

thunderstorm

4
Syllable

Thanksgiving Day

theatrical

therapeutic

thermometer

thundershower

5
Syllable

theologian

thermodynamic

Medial Voiceless TH by Syllables


2
Syllable

athlete

author

bathmat

bathtub

breathless

ethics

fifth grade

method

misthink

mouthwash

nothing

pathway

rethink

something

southeast

southward

toothache

toothbrush

truthful

youthful

3
Syllable

anything

athletic

authentic

authorize

authorship

bath towel

bath water

breath taking

coauthor

empathy

everything

marathon

math homework

pathetic

stethoscope

sympathize

sympathy

thirty third

tooth fairy

youth soccer

4
Syllable

arithmetic

athletic club

authority

group therapy

hypothesis

hypothetic

mathematics

mythology

pathologist

play therapy

South Africa

South Dakota

South Korea

South Pacific

sympathetic

5
Syllable

amphitheater

anesthesia

authenticity

South America

South Carolina

Final Voiceless TH by Syllables


2
Syllable

bear with

beneath

bike path

birdbath

blacksmith

dishcloth

dog tooth

goldsmith

hot bath

locksmith

mammoth

phone booth

steam bath

sweet tooth

toll booth

untruth

3
Syllable

aftermath

baby's breath

baby teeth

bubble bath

chicken broth

eightieth

fiftieth

fortieth

ninetieth

silversmith

sixtieth

tablecloth

thirtieth

twentieth

undergrowth

underneath

wisdom teeth

4
Syllable

Elizabeth

seventieth

telephone booth

5
Syllable



Initial Voiceless TH Phrases and Sentences


thank you note

empty thermos

thick meat

sneaky thief

sore thigh

thin slice

think often

third birthday

very thirsty

number thirteen

turn 30

sharp thorn

blue thread

number three

thumbs up

green thumbtack

noisy thunder

Thursday night

She left a thank you note on the computer.

I have hot chocolate in my thermos.

I like to eat thick steaks.

He is a car thief.

His thigh was sore from working hard.

We asked for thin sliced roast beef.

She goes to the park to think.

Today is her third birthday.

The boy was thirsty after running.

My address is 13 Park Place.

She turned thirty in May.

The rose bush has a sharp thorn on it.

WIll you grab the blue thread?

She hung a three on the side of her house.

She gave him a thumbs up.

I put a thumbtack on the map.

The thunder was loud.

The party is on Thursday night.

Medial Voiceless TH Phrases and Sentences


competitive athlete

mystery author

white bathrobe

big bathtub

birthday party

breathless runner

massive earthquake

healthy eating

green mouthwash

have nothing

black panther

big python

blue stethoscope

bad toothache

orange toothbrush

green toothpaste

short toothpick

youthful grandparents

The athlete entered the high jump event.

The author mostly wrote mysteries.

My bathrobe is nice and soft.

She wanted to clean her bathtub.

He invited his friends to his birthday party.

He ran so much he was breathless.

The earthquake destroyed the road.

They are eating healthy food.

Mouthwash makes your mouth feel fresh.

There is nothing in his pockets.

The panther is resting.

The python is wrapped around the tree.

The stethoscope is on the floor.

Her toothache was painful.

The dentist gave her a new toothbrush.

Toothpaste will help keep your teeth clean.

He has a toothpick in his mouth.

My grandparents are very youthful.

Final Voiceless TH Phrases and Sentences

hot bath

strong blacksmith

phone booth

see your breath

planet earth

fifth person

fourth place

nice locksmith

math problem

spotted moth

girl mouth

head north

under oath

long path

drive south

pretty teeth

white tooth

holiday wreath

He took a nice hot bath.

The blacksmith makes old-fashioned swords.

She made a call from the phone booth.

She could see her breath in the cold.

We live on planet earth.

She was the fifth person in line.

He came in fourth in the race.

The locksmith is fixing it.

She is working on a math problem.

The moth landed on the branch.

She has white teeth in her mouth.

The compass said to walk north.

She made an oath to tell the truth.

It is a long path through the woods.

They followed the sign to go south.

She has very white teeth.

The dentist pulled her tooth.

The door has a beautiful wreath on it.

Voiceless TH Reading Paragraphs


Thatch's Goals

The boy playing third base is good. His name is Thatcher, but his friends call him Thatch. His baseball team is called "Blue Thunder". He is from South Dakota and he's very athletic. 

Thatch plays third base on the baseball team. He also plays basketball, tennis, and youth soccer - not bad for a thirteen-year-old. He has been playing sports since he was three. Thatch wants to play one or all of the sports professionally someday. 

Last month I asked him if he had thought about which sport he wanted to play. 

"I'll play anything if I can get paid to do it," he said. 

I told him I thought he would be a pro baseball player and he gave me a thumbs up. 

He is on the right path if playing pro sports is his dream. He was voted third for the best player in the state and tenth for best player in the region three weeks ago. His parents think he will play tennis, but said they don't have the authority to make that decision. 

The earth has a lot of great sports players and I think Thatch can play with the best of them. I hope nothing gets in his way. It will be fun to say I knew him when he was only thirteen.

Exploding Cake

Thad liked to prank and scare people. He played the most jokes on people when he was in the fifth grade. He put thumbtacks on chairs, thickener in drinks, and told the class that their pet python had escaped. His favorite pranks were to turn the thermostat down really cold to try and freeze students out and to replace student's soda with mouthwash. 

A few days ago, Thea brought in a cake to celebrate her birthday. Somehow, Thad got a balloon inside of it so when the teacher tried to cut the cake, it exploded all over everyone. 

Thad had a lot of fun thinking of new ways to prank his classmates. His teacher, Ms. South, didn't think it was healthy. She knew Thad was a very thoughtful writer. He was also very smart in math. She thought his writing was so good that he could become an author someday. 

Overall, Thad's grades were in the top three percent of his class. Ms. South didn't want Thad's talent and thoughtfulness go to waste. She thought about what methods she could use to help him focus in class and not cause so much trouble. Thad wanted to be in theater after he graduated high school. Ms. South told Thad that he could be in theater after he graduated. 

"You're so smart! I think a thousand theaters would want you to work for them, but you have to stop the pranks," she said. Thad started to rethink his actions and what that would mean for him in the future. He apologized to the class and Ms. South, and said he would not prank anyone anymore. 

Turning Thirty

Thelma's birthday was on Thursday and she couldn't decide how to celebrate. She was turning thirty and wanted this birthday to be special. 

One idea she had was going to a steak house. A thick juicy steak would be part of a perfect meal for her birthday. Going to the spa and getting a massage would be therapeutic. Of course, that can be expensive, so if necessary she could just take a warm bubble bath. 

Something she really wanted to do was sit outside and eat popcorn during a thunderstorm, but she couldn't control the weather, so she would keep that as a backup plan. She had always wanted to visit South America too, but would have to save her money for a trip like that. Thelma thought about a short trip she could take and remembered the zoo was close by. 

"The zoo had pythons, panthers, and a new mammoth exhibit, and those would be fun to see," she thought. All of this thinking was taking her strength. Thelma only had three hours of sleep last night because she had been up reading a case study for her ethics class. A moth had flown in her house and distracted her while reading. The distraction had kept her up later than she planned. 

Thelma thought for a minute and decided that she would take a nap. "Everything will fall into place on Thursday," she thought, "As long as I know what I want to do, everything will work out." She closed her eyes, her breath softened, and she fell asleep on her couch. 




This list of functional words was professionally selected to be the most useful for a child or adult who has difficulty with producing the "Voiceless TH" sound.

We encourage you to use this list when practicing at home.

Doing home practice will help your child make much faster progress toward correct production.

Speech-Language Pathologists (SLPs) are only able to see students/clients 30-60 mins (or less) per week.

This is not enough time for your child to overcome an articulation disorder with the "Voiceless TH" sound. But with high caseloads


More reference: https://www.home-speech-home.com/voiceless-th-words.html